refactor(web): dependency management (#2386)
This commit is contained in:
@@ -1,19 +1,13 @@
|
||||
import { WebApplicationInterface } from './../../WebApplication/WebApplicationInterface'
|
||||
import { NativeFeatureIdentifier, NoteType } from '@standardnotes/features'
|
||||
import { AegisToAuthenticatorConverter } from './AegisToAuthenticatorConverter'
|
||||
import data from './testData'
|
||||
import { UuidGenerator } from '@standardnotes/utils'
|
||||
|
||||
UuidGenerator.SetGenerator(() => String(Math.random()))
|
||||
|
||||
describe('AegisConverter', () => {
|
||||
let application: WebApplicationInterface
|
||||
|
||||
beforeEach(() => {
|
||||
application = {
|
||||
generateUUID: jest.fn().mockReturnValue('test'),
|
||||
} as unknown as WebApplicationInterface
|
||||
})
|
||||
|
||||
it('should parse entries', () => {
|
||||
const converter = new AegisToAuthenticatorConverter(application)
|
||||
const converter = new AegisToAuthenticatorConverter()
|
||||
|
||||
const result = converter.parseEntries(data)
|
||||
|
||||
@@ -34,7 +28,7 @@ describe('AegisConverter', () => {
|
||||
})
|
||||
|
||||
it('should create note from entries with editor info', () => {
|
||||
const converter = new AegisToAuthenticatorConverter(application)
|
||||
const converter = new AegisToAuthenticatorConverter()
|
||||
|
||||
const parsedEntries = converter.parseEntries(data)
|
||||
|
||||
@@ -61,7 +55,7 @@ describe('AegisConverter', () => {
|
||||
})
|
||||
|
||||
it('should create note from entries without editor info', () => {
|
||||
const converter = new AegisToAuthenticatorConverter(application)
|
||||
const converter = new AegisToAuthenticatorConverter()
|
||||
|
||||
const parsedEntries = converter.parseEntries(data)
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { DecryptedTransferPayload, NoteContent } from '@standardnotes/models'
|
||||
import { readFileAsText } from '../Utils'
|
||||
import { NativeFeatureIdentifier, NoteType } from '@standardnotes/features'
|
||||
import { WebApplicationInterface } from '../../WebApplication/WebApplicationInterface'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { UuidGenerator } from '@standardnotes/utils'
|
||||
|
||||
type AegisData = {
|
||||
db: {
|
||||
@@ -27,9 +27,11 @@ type AuthenticatorEntry = {
|
||||
}
|
||||
|
||||
export class AegisToAuthenticatorConverter {
|
||||
constructor(protected application: WebApplicationInterface) {}
|
||||
constructor() {}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
static isValidAegisJson(json: any): boolean {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return json.db && json.db.entries && json.db.entries.every((entry: any) => AegisEntryTypes.includes(entry.type))
|
||||
}
|
||||
|
||||
@@ -61,7 +63,7 @@ export class AegisToAuthenticatorConverter {
|
||||
created_at_timestamp: file.lastModified,
|
||||
updated_at: new Date(file.lastModified),
|
||||
updated_at_timestamp: file.lastModified,
|
||||
uuid: this.application.generateUUID(),
|
||||
uuid: UuidGenerator.GenerateUuid(),
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: {
|
||||
title: file.name.split('.')[0],
|
||||
|
||||
Reference in New Issue
Block a user