1- import * as commonSdk from '@powersync/common' ;
21import { beforeEach , describe , expect , it , vi } from 'vitest' ;
3- import { AbstractAttachmentQueue } from '../../src/AbstractAttachmentQueue' ;
4- import { AttachmentRecord , AttachmentState } from '../../src/Schema' ;
5- import { AbstractPowerSyncDatabase } from '@powersync/common' ;
6- import { StorageAdapter } from '../../src/StorageAdapter' ;
2+ import { AbstractAttachmentQueue } from '../../src/AbstractAttachmentQueue.js' ;
3+ import { AttachmentRecord , AttachmentState } from '../../src/Schema.js' ;
4+ import { StorageAdapter } from '../../src/StorageAdapter.js' ;
75
86const record = {
97 id : 'test-1' ,
108 filename : 'test.jpg' ,
119 state : AttachmentState . QUEUED_DOWNLOAD
12- }
10+ } ;
1311
1412const mockPowerSync = {
1513 currentStatus : { status : 'initial' } ,
1614 registerListener : vi . fn ( ( ) => { } ) ,
1715 resolveTables : vi . fn ( ( ) => [ 'table1' , 'table2' ] ) ,
1816 onChangeWithCallback : vi . fn ( ) ,
19- getAll : vi . fn ( ( ) => Promise . resolve ( [ { id : 'test-1' } , { id : 'test-2' } ] ) ) ,
17+ getAll : vi . fn ( ( ) => Promise . resolve ( [ { id : 'test-1' } , { id : 'test-2' } ] ) ) ,
2018 execute : vi . fn ( ( ) => Promise . resolve ( ) ) ,
2119 getOptional : vi . fn ( ( _query , params ) => Promise . resolve ( record ) ) ,
2220 watch : vi . fn ( ( query , params , callbacks ) => {
23- callbacks ?. onResult ?.( { rows : { _array : [ { id : 'test-1' } , { id : 'test-2' } ] } } ) ;
21+ callbacks ?. onResult ?.( { rows : { _array : [ { id : 'test-1' } , { id : 'test-2' } ] } } ) ;
2422 } ) ,
2523 writeTransaction : vi . fn ( async ( callback ) => {
2624 await callback ( {
@@ -57,9 +55,9 @@ describe('attachments', () => {
5755
5856 it ( 'should not download attachments when downloadRecord is called with downloadAttachments false' , async ( ) => {
5957 const queue = new TestAttachmentQueue ( {
60- powersync : mockPowerSync as any ,
61- storage : mockStorage ,
62- downloadAttachments : false
58+ powersync : mockPowerSync as any ,
59+ storage : mockStorage ,
60+ downloadAttachments : false
6361 } ) ;
6462
6563 await queue . downloadRecord ( record ) ;
@@ -69,9 +67,9 @@ describe('attachments', () => {
6967
7068 it ( 'should download attachments when downloadRecord is called with downloadAttachments true' , async ( ) => {
7169 const queue = new TestAttachmentQueue ( {
72- powersync : mockPowerSync as any ,
73- storage : mockStorage ,
74- downloadAttachments : true
70+ powersync : mockPowerSync as any ,
71+ storage : mockStorage ,
72+ downloadAttachments : true
7573 } ) ;
7674
7775 await queue . downloadRecord ( record ) ;
@@ -82,9 +80,9 @@ describe('attachments', () => {
8280 // Testing the inverse of this test, i.e. when downloadAttachments is false, is not required as you can't wait for something that does not happen
8381 it ( 'should not download attachments with watchDownloads is called with downloadAttachments false' , async ( ) => {
8482 const queue = new TestAttachmentQueue ( {
85- powersync : mockPowerSync as any ,
86- storage : mockStorage ,
87- downloadAttachments : true
83+ powersync : mockPowerSync as any ,
84+ storage : mockStorage ,
85+ downloadAttachments : true
8886 } ) ;
8987
9088 queue . watchDownloads ( ) ;
0 commit comments