1- import { readFileSync } from 'fs' ;
1+ import { readFileSync , statSync } from 'fs' ;
22import { join } from 'path' ;
33import { Tools } from './sntools' ;
44
@@ -125,7 +125,7 @@ describe('sn-tools', () => {
125125 uuid : expect . stringMatching ( uuidFormat ) ,
126126 content_type : 'Note' ,
127127 content : {
128- title : 'Imported note 2 from ENote ' ,
128+ title : 'Imported note 2 from Evernote ' ,
129129 text : '<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>' ,
130130 references : [ ] ,
131131 appData : {
@@ -142,7 +142,7 @@ describe('sn-tools', () => {
142142 uuid : expect . stringMatching ( uuidFormat ) ,
143143 content_type : 'Note' ,
144144 content : {
145- title : 'Imported note 2 from ENote ' ,
145+ title : 'Imported note 2 from Evernote ' ,
146146 text : 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.' ,
147147 references : [ ] ,
148148 appData : {
@@ -175,6 +175,67 @@ describe('sn-tools', () => {
175175 } ) ;
176176 } ) ;
177177
178+ describe ( 'convertAegisToSN()' , ( ) => {
179+ const filePath = join ( __dirname , '../test/data/aegis/backup.json' ) ;
180+ const content = readFileSync ( filePath ) ;
181+ const metadata = statSync ( filePath ) ;
182+ const parsedFile = tools . convertAegisFile ( {
183+ name : 'backup.json' ,
184+ lastModified : metadata . mtime ,
185+ content,
186+ } ) ;
187+
188+ it ( 'should return 2 valid items' , ( ) => {
189+ expect ( parsedFile ) . not . toBe ( undefined ) ;
190+ expect ( parsedFile . items ) . toBeDefined ( ) ;
191+ expect ( parsedFile . items . length ) . toBe ( 2 ) ; // 1 Note and 1 Tag
192+
193+ expect ( parsedFile ) . not . toBe ( undefined ) ;
194+ expect ( parsedFile . items ) . toBeDefined ( ) ;
195+ expect ( parsedFile . items . length ) . toBe ( 2 ) ; // 1 Note and 1 Tag
196+ } ) ;
197+
198+ const { items } = parsedFile ;
199+
200+ const firstItem = items [ 0 ] ;
201+ const secondItem = items [ 1 ] ;
202+
203+ test ( "first item should be a Tag" , ( ) => {
204+ expect ( firstItem ) . toEqual ( {
205+ uuid : expect . stringMatching ( uuidFormat ) ,
206+ content_type : 'Tag' ,
207+ content : {
208+ title : `${ new Date ( '2022-03-13' ) . toLocaleDateString ( ) . replace ( / \/ / g, '-' ) } -import` ,
209+ references : [
210+ {
211+ content_type : 'Note' ,
212+ uuid : secondItem . uuid
213+ }
214+ ]
215+ }
216+ } ) ;
217+ } ) ;
218+
219+ test ( "second item should be a Note" , ( ) => {
220+ expect ( secondItem ) . toEqual ( {
221+ created_at : new Date ( metadata . mtime ) ,
222+ updated_at : new Date ( metadata . mtime ) ,
223+ uuid : expect . stringMatching ( uuidFormat ) ,
224+ content_type : "Note" ,
225+ content : {
226+ title : "backup" ,
227+ text : "[{\"service\":\"TestMail\",\"account\":\"test@test.com\",\"secret\":\"TESTMAILTESTMAILTESTMAILTESTMAIL\",\"notes\":\"Some note\"},{\"service\":\"Some Service\",\"account\":\"test@test.com\",\"secret\":\"SOMESERVICESOMESERVICESOMESERVIC\",\"notes\":\"Some other service\"}]" ,
228+ references : [ ] ,
229+ appData : {
230+ "org.standardnotes.sn" : {
231+ client_updated_at : new Date ( metadata . mtime ) ,
232+ } ,
233+ } ,
234+ } ,
235+ } ) ;
236+ } ) ;
237+ } ) ;
238+
178239 describe ( 'convertGKeepNotes()' , ( ) => {
179240 const filesPath = join ( __dirname , '../test/data/google-keep' ) ;
180241 const exportFile1 = readFileSync ( join ( filesPath , 'note-1.json' ) ) ;
0 commit comments