1
0
mirror of https://github.com/bitwarden/browser synced 2024-12-15 10:48:59 +01:00
bitwarden-estensione-browser/libs/common/spec/services/import.service.spec.ts
Daniel James Smith 0e78910582
[PS-1805] BEEEP: Renamed importers based on agreed naming-convention (#3978)
* Rename all importer related files

Renamed all files based on our naming convention which we decided on with https://github.com/bitwarden/adr/blob/master/decisions/0012-angular-filename-convention.md

* Removed entries from whitelist-capital-letters.txt

* Rename missing safeInCloud test data

* Fix broken import

* Renamed folders (removed capital letters)

* Fix filename of BitwardenCsvImporter

* Fix imports of onepassword mac/win importer tests

* Remove already renamed folders from whitelist

* Rename dashlaneImporters to dashlane

Rename the folder
Fix all the imports
Remove dashlaneImporters from white-list

* Rename keeperImporters to keeper

Rename the folder
Fix all the imports
Remove keeperImporters from white-list

* Rename onepasswordImporters to onepassword

Rename the folder
Fix all the imports
Remove onepasswordImporters from white-list

* Rename safeinCloud test data folder

* Fix onepassword importer type imports
2022-11-11 16:20:03 +01:00

70 lines
2.6 KiB
TypeScript

// eslint-disable-next-line no-restricted-imports
import { Substitute, SubstituteOf } from "@fluffy-spoon/substitute";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { CipherService } from "@bitwarden/common/abstractions/cipher.service";
import { CollectionService } from "@bitwarden/common/abstractions/collection.service";
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
import { FolderService } from "@bitwarden/common/abstractions/folder/folder.service.abstraction";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { BitwardenPasswordProtectedImporter } from "@bitwarden/common/importers/bitwarden-password-protected-importer";
import { Importer } from "@bitwarden/common/importers/importer";
import { Utils } from "@bitwarden/common/misc/utils";
import { ImportService } from "@bitwarden/common/services/import.service";
describe("ImportService", () => {
let importService: ImportService;
let cipherService: SubstituteOf<CipherService>;
let folderService: SubstituteOf<FolderService>;
let apiService: SubstituteOf<ApiService>;
let i18nService: SubstituteOf<I18nService>;
let collectionService: SubstituteOf<CollectionService>;
let cryptoService: SubstituteOf<CryptoService>;
beforeEach(() => {
cipherService = Substitute.for<CipherService>();
folderService = Substitute.for<FolderService>();
apiService = Substitute.for<ApiService>();
i18nService = Substitute.for<I18nService>();
collectionService = Substitute.for<CollectionService>();
cryptoService = Substitute.for<CryptoService>();
importService = new ImportService(
cipherService,
folderService,
apiService,
i18nService,
collectionService,
cryptoService
);
});
describe("getImporterInstance", () => {
describe("Get bitPasswordProtected importer", () => {
let importer: Importer;
const organizationId = Utils.newGuid();
const password = Utils.newGuid();
beforeEach(() => {
importer = importService.getImporter(
"bitwardenpasswordprotected",
organizationId,
password
);
});
it("returns an instance of BitwardenPasswordProtectedImporter", () => {
expect(importer).toBeInstanceOf(BitwardenPasswordProtectedImporter);
});
it("has the appropriate organization Id", () => {
expect(importer.organizationId).toEqual(organizationId);
});
it("has the appropriate password", () => {
expect(Object.entries(importer)).toEqual(expect.arrayContaining([["password", password]]));
});
});
});
});