mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-05 09:10:53 +01:00
a4fba0e1c5
* Switch to jest * Fix jslib-angular package name * Make angular test project * Split up tests by jslib project * Remove obsolete node test script * Use legacy deps with jest-preset-angular * Move web tests to common * Remove build from pipeline This was only being used because we were not using ts runners. We are now, so build is unnecessary
32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import { Substitute, SubstituteOf } from "@fluffy-spoon/substitute";
|
|
|
|
import { CryptoService } from "jslib-common/abstractions/crypto.service";
|
|
import { I18nService } from "jslib-common/abstractions/i18n.service";
|
|
import { BitwardenJsonImporter } from "jslib-common/importers/bitwardenJsonImporter";
|
|
|
|
import { data as passwordProtectedData } from "./testData/bitwardenJson/passwordProtected.json";
|
|
|
|
describe("bitwarden json importer", () => {
|
|
let sut: BitwardenJsonImporter;
|
|
let cryptoService: SubstituteOf<CryptoService>;
|
|
let i18nService: SubstituteOf<I18nService>;
|
|
|
|
beforeEach(() => {
|
|
cryptoService = Substitute.for<CryptoService>();
|
|
i18nService = Substitute.for<I18nService>();
|
|
|
|
sut = new BitwardenJsonImporter(cryptoService, i18nService);
|
|
});
|
|
|
|
it("should fail if password is needed", async () => {
|
|
expect((await sut.parse(passwordProtectedData)).success).toBe(false);
|
|
});
|
|
|
|
it("should return password needed error message", async () => {
|
|
const expected = "Password required error message";
|
|
i18nService.t("importPasswordRequired").returns(expected);
|
|
|
|
expect((await sut.parse(passwordProtectedData)).errorMessage).toEqual(expected);
|
|
});
|
|
});
|