1
0
mirror of https://github.com/bitwarden/browser synced 2024-12-13 17:57:09 +01:00
bitwarden-estensione-browser/spec/common/importers/onepasswordCsvImporter.spec.ts
2020-12-04 21:05:11 -05:00

51 lines
1.7 KiB
TypeScript

import { OnePasswordWinCsvImporter as Importer } from '../../../src/importers/onepasswordWinCsvImporter';
import { CipherType } from '../../../src/enums';
import { data as creditCardData } from './testData/onePasswordCsv/creditCard.csv'
import { data as identityData } from './testData/onePasswordCsv/identity.csv'
describe('1Password CSV Importer', () => {
it('should parse identity imports', async () => {
const importer = new Importer();
const result = await importer.parse(identityData);
expect(result).not.toBeNull();
expect(result.success).toBe(true);
expect(result.ciphers.length).toBe(1);
const cipher = result.ciphers[0];
expect(cipher.type).toBe(CipherType.Identity)
expect(cipher.identity).toEqual(jasmine.objectContaining({
firstName: 'first name',
middleName: 'mi',
lastName: 'last name',
username: 'userNam3',
company: 'bitwarden',
phone: '8005555555',
email: 'email@bitwarden.com'
}));
expect(cipher.notes).toContain('address\ncity state zip\nUnited States');
});
it('should parse credit card imports', async () => {
const importer = new Importer();
const result = await importer.parse(creditCardData);
expect(result).not.toBeNull();
expect(result.success).toBe(true);
expect(result.ciphers.length).toBe(1);
const cipher = result.ciphers[0];
expect(cipher.type).toBe(CipherType.Card);
expect(cipher.card).toEqual(jasmine.objectContaining({
number: '4111111111111111',
code: '111',
cardholderName: 'test',
expMonth: '1',
expYear: '2030',
}));
});
});