refactor(web): dependency management (#2386)

This commit is contained in:
Mo
2023-08-05 12:48:39 -05:00
committed by GitHub
parent b07da5b663
commit d8d4052a52
274 changed files with 4065 additions and 3873 deletions

View File

@@ -4,19 +4,13 @@
import { jsonTestData, htmlTestData } from './testData'
import { GoogleKeepConverter } from './GoogleKeepConverter'
import { WebApplicationInterface } from '../../WebApplication/WebApplicationInterface'
import { UuidGenerator } from '@standardnotes/utils'
UuidGenerator.SetGenerator(() => String(Math.random()))
describe('GoogleKeepConverter', () => {
let application: WebApplicationInterface
beforeEach(() => {
application = {
generateUUID: jest.fn().mockReturnValue('uuid'),
} as unknown as WebApplicationInterface
})
it('should parse json data', () => {
const converter = new GoogleKeepConverter(application)
const converter = new GoogleKeepConverter()
const result = converter.tryParseAsJson(jsonTestData)
@@ -33,7 +27,7 @@ describe('GoogleKeepConverter', () => {
})
it('should parse html data', () => {
const converter = new GoogleKeepConverter(application)
const converter = new GoogleKeepConverter()
const result = converter.tryParseAsHtml(
htmlTestData,

View File

@@ -1,7 +1,7 @@
import { ContentType } from '@standardnotes/domain-core'
import { DecryptedTransferPayload, NoteContent } from '@standardnotes/models'
import { readFileAsText } from '../Utils'
import { WebApplicationInterface } from '../../WebApplication/WebApplicationInterface'
import { UuidGenerator } from '@standardnotes/utils'
type GoogleKeepJsonNote = {
color: string
@@ -14,7 +14,7 @@ type GoogleKeepJsonNote = {
}
export class GoogleKeepConverter {
constructor(protected application: WebApplicationInterface) {}
constructor() {}
async convertGoogleKeepBackupFileToNote(
file: File,
@@ -66,7 +66,7 @@ export class GoogleKeepConverter {
created_at_timestamp: date.getTime(),
updated_at: date,
updated_at_timestamp: date.getTime(),
uuid: this.application.generateUUID(),
uuid: UuidGenerator.GenerateUuid(),
content_type: ContentType.TYPES.Note,
content: {
title: title,
@@ -96,6 +96,7 @@ export class GoogleKeepConverter {
return
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static isValidGoogleKeepJson(json: any): boolean {
return (
typeof json.title === 'string' &&
@@ -120,7 +121,7 @@ export class GoogleKeepConverter {
created_at_timestamp: date.getTime(),
updated_at: date,
updated_at_timestamp: date.getTime(),
uuid: this.application.generateUUID(),
uuid: UuidGenerator.GenerateUuid(),
content_type: ContentType.TYPES.Note,
content: {
title: parsed.title,