@@ -3,7 +3,8 @@ import assert from 'assert';
33import { Readable } from 'stream' ;
44import { promisify } from 'util' ;
55import { FileBreadcrumbsStorage } from '../../src/breadcrumbs/FileBreadcrumbsStorage.js' ;
6- import { mockStreamFileSystem } from '../_mocks/storage.js' ;
6+ import { NodeFsBacktraceFileAttachmentFactory } from '../../src/index.js' ;
7+ import { mockNodeStorageAndFs } from '../_mocks/storage.js' ;
78
89async function readToEnd ( readable : Readable ) {
910 return new Promise < Buffer > ( ( resolve , reject ) => {
@@ -33,8 +34,8 @@ const nextTick = promisify(process.nextTick);
3334
3435describe ( 'FileBreadcrumbsStorage' , ( ) => {
3536 it ( 'should return added breadcrumbs' , async ( ) => {
36- const fs = mockStreamFileSystem ( ) ;
37- const session = new SessionFiles ( fs , 'sessionId' ) ;
37+ const fs = mockNodeStorageAndFs ( ) ;
38+ const session = new SessionFiles ( fs , { id : 'sessionId' , timestamp : Date . now ( ) } ) ;
3839
3940 const breadcrumbs : RawBreadcrumb [ ] = [
4041 {
@@ -86,7 +87,7 @@ describe('FileBreadcrumbsStorage', () => {
8687 } ,
8788 ] ;
8889
89- const storage = new FileBreadcrumbsStorage ( session , fs , {
90+ const storage = new FileBreadcrumbsStorage ( session , fs , new NodeFsBacktraceFileAttachmentFactory ( fs ) , {
9091 maximumBreadcrumbs : 100 ,
9192 } ) ;
9293
@@ -107,8 +108,8 @@ describe('FileBreadcrumbsStorage', () => {
107108 } ) ;
108109
109110 it ( 'should return added breadcrumbs in two attachments' , async ( ) => {
110- const fs = mockStreamFileSystem ( ) ;
111- const session = new SessionFiles ( fs , 'sessionId' ) ;
111+ const fs = mockNodeStorageAndFs ( ) ;
112+ const session = new SessionFiles ( fs , { id : 'sessionId' , timestamp : Date . now ( ) } ) ;
112113
113114 const breadcrumbs : RawBreadcrumb [ ] = [
114115 {
@@ -163,7 +164,7 @@ describe('FileBreadcrumbsStorage', () => {
163164 } ,
164165 ] ;
165166
166- const storage = new FileBreadcrumbsStorage ( session , fs , {
167+ const storage = new FileBreadcrumbsStorage ( session , fs , new NodeFsBacktraceFileAttachmentFactory ( fs ) , {
167168 maximumBreadcrumbs : 4 ,
168169 } ) ;
169170
@@ -189,8 +190,8 @@ describe('FileBreadcrumbsStorage', () => {
189190 } ) ;
190191
191192 it ( 'should return no more than maximumBreadcrumbs breadcrumbs' , async ( ) => {
192- const fs = mockStreamFileSystem ( ) ;
193- const session = new SessionFiles ( fs , 'sessionId' ) ;
193+ const fs = mockNodeStorageAndFs ( ) ;
194+ const session = new SessionFiles ( fs , { id : 'sessionId' , timestamp : Date . now ( ) } ) ;
194195
195196 const breadcrumbs : RawBreadcrumb [ ] = [
196197 {
@@ -235,7 +236,7 @@ describe('FileBreadcrumbsStorage', () => {
235236 } ,
236237 ] ;
237238
238- const storage = new FileBreadcrumbsStorage ( session , fs , {
239+ const storage = new FileBreadcrumbsStorage ( session , fs , new NodeFsBacktraceFileAttachmentFactory ( fs ) , {
239240 maximumBreadcrumbs : 2 ,
240241 } ) ;
241242
@@ -261,8 +262,8 @@ describe('FileBreadcrumbsStorage', () => {
261262 } ) ;
262263
263264 it ( 'should return breadcrumbs up to the json size' , async ( ) => {
264- const fs = mockStreamFileSystem ( ) ;
265- const session = new SessionFiles ( fs , 'sessionId' ) ;
265+ const fs = mockNodeStorageAndFs ( ) ;
266+ const session = new SessionFiles ( fs , { id : 'sessionId' , timestamp : Date . now ( ) } ) ;
266267
267268 const breadcrumbs : RawBreadcrumb [ ] = [
268269 {
@@ -302,7 +303,7 @@ describe('FileBreadcrumbsStorage', () => {
302303 } ,
303304 ] ;
304305
305- const storage = new FileBreadcrumbsStorage ( session , fs , {
306+ const storage = new FileBreadcrumbsStorage ( session , fs , new NodeFsBacktraceFileAttachmentFactory ( fs ) , {
306307 maximumBreadcrumbs : 100 ,
307308 maximumTotalBreadcrumbsSize : JSON . stringify ( expectedMain [ 0 ] ) . length + 10 ,
308309 } ) ;
@@ -329,8 +330,8 @@ describe('FileBreadcrumbsStorage', () => {
329330 } ) ;
330331
331332 it ( 'should return attachments with a valid name from getAttachments' , async ( ) => {
332- const fs = mockStreamFileSystem ( ) ;
333- const session = new SessionFiles ( fs , 'sessionId' ) ;
333+ const fs = mockNodeStorageAndFs ( ) ;
334+ const session = new SessionFiles ( fs , { id : 'sessionId' , timestamp : Date . now ( ) } ) ;
334335
335336 const breadcrumbs : RawBreadcrumb [ ] = [
336337 {
@@ -354,7 +355,7 @@ describe('FileBreadcrumbsStorage', () => {
354355 } ,
355356 ] ;
356357
357- const storage = new FileBreadcrumbsStorage ( session , fs , {
358+ const storage = new FileBreadcrumbsStorage ( session , fs , new NodeFsBacktraceFileAttachmentFactory ( fs ) , {
358359 maximumBreadcrumbs : 4 ,
359360 } ) ;
360361
@@ -373,8 +374,8 @@ describe('FileBreadcrumbsStorage', () => {
373374 } ) ;
374375
375376 it ( 'should return attachments with a valid name from getAttachmentProviders' , async ( ) => {
376- const fs = mockStreamFileSystem ( ) ;
377- const session = new SessionFiles ( fs , 'sessionId' ) ;
377+ const fs = mockNodeStorageAndFs ( ) ;
378+ const session = new SessionFiles ( fs , { id : 'sessionId' , timestamp : Date . now ( ) } ) ;
378379
379380 const breadcrumbs : RawBreadcrumb [ ] = [
380381 {
@@ -398,7 +399,7 @@ describe('FileBreadcrumbsStorage', () => {
398399 } ,
399400 ] ;
400401
401- const storage = new FileBreadcrumbsStorage ( session , fs , {
402+ const storage = new FileBreadcrumbsStorage ( session , fs , new NodeFsBacktraceFileAttachmentFactory ( fs ) , {
402403 maximumBreadcrumbs : 4 ,
403404 } ) ;
404405
0 commit comments