chore: fix uuid generation for importers
This commit is contained in:
@@ -1,13 +1,18 @@
|
||||
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
|
||||
import { NativeFeatureIdentifier, NoteType } from '@standardnotes/features'
|
||||
import { AegisToAuthenticatorConverter } from './AegisToAuthenticatorConverter'
|
||||
import data from './testData'
|
||||
import { UuidGenerator } from '@standardnotes/utils'
|
||||
|
||||
UuidGenerator.SetGenerator(() => String(Math.random()))
|
||||
import { GenerateUuid } from '@standardnotes/services'
|
||||
|
||||
describe('AegisConverter', () => {
|
||||
const crypto = {
|
||||
generateUUID: () => String(Math.random()),
|
||||
} as unknown as PureCryptoInterface
|
||||
|
||||
const generateUuid = new GenerateUuid(crypto)
|
||||
|
||||
it('should parse entries', () => {
|
||||
const converter = new AegisToAuthenticatorConverter()
|
||||
const converter = new AegisToAuthenticatorConverter(generateUuid)
|
||||
|
||||
const result = converter.parseEntries(data)
|
||||
|
||||
@@ -28,7 +33,7 @@ describe('AegisConverter', () => {
|
||||
})
|
||||
|
||||
it('should create note from entries with editor info', () => {
|
||||
const converter = new AegisToAuthenticatorConverter()
|
||||
const converter = new AegisToAuthenticatorConverter(generateUuid)
|
||||
|
||||
const parsedEntries = converter.parseEntries(data)
|
||||
|
||||
@@ -55,7 +60,7 @@ describe('AegisConverter', () => {
|
||||
})
|
||||
|
||||
it('should create note from entries without editor info', () => {
|
||||
const converter = new AegisToAuthenticatorConverter()
|
||||
const converter = new AegisToAuthenticatorConverter(generateUuid)
|
||||
|
||||
const parsedEntries = converter.parseEntries(data)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { DecryptedTransferPayload, NoteContent } from '@standardnotes/models'
|
||||
import { readFileAsText } from '../Utils'
|
||||
import { NativeFeatureIdentifier, NoteType } from '@standardnotes/features'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { UuidGenerator } from '@standardnotes/utils'
|
||||
import { GenerateUuid } from '@standardnotes/services'
|
||||
|
||||
type AegisData = {
|
||||
db: {
|
||||
@@ -27,7 +27,7 @@ type AuthenticatorEntry = {
|
||||
}
|
||||
|
||||
export class AegisToAuthenticatorConverter {
|
||||
constructor() {}
|
||||
constructor(private _generateUuid: GenerateUuid) {}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
static isValidAegisJson(json: any): boolean {
|
||||
@@ -63,7 +63,7 @@ export class AegisToAuthenticatorConverter {
|
||||
created_at_timestamp: file.lastModified,
|
||||
updated_at: new Date(file.lastModified),
|
||||
updated_at_timestamp: file.lastModified,
|
||||
uuid: UuidGenerator.GenerateUuid(),
|
||||
uuid: this._generateUuid.execute().getValue(),
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: {
|
||||
title: file.name.split('.')[0],
|
||||
|
||||
Reference in New Issue
Block a user