@@ -9,10 +9,12 @@ import {BehaviorSubject} from 'rxjs';
99import { setup as remoteSetup } from '../../../remote/__tests__/setup' ;
1010import { tick } from 'thingies' ;
1111
12- const setup = async ( opts : {
13- remote ?: ReturnType < typeof remoteSetup > ;
14- local ?: Partial < ServerCrudLocalHistoryOpts > ;
15- } = { } ) => {
12+ const setup = async (
13+ opts : {
14+ remote ?: ReturnType < typeof remoteSetup > ;
15+ local ?: Partial < ServerCrudLocalHistoryOpts > ;
16+ } = { } ,
17+ ) => {
1618 const remote = opts . remote ?? remoteSetup ( ) ;
1719 const { fs, vol} = memfs ( ) ;
1820 const printFs = ( ) => console . log ( toTreeSync ( fs ) ) ;
@@ -65,7 +67,7 @@ describe('.create()', () => {
6567 const res = await kit . local . create ( [ 'collection' ] , kit . log , kit . id ) ;
6668 expect ( res ) . toMatchObject ( {
6769 id : kit . id ,
68- remote : expect . any ( Promise )
70+ remote : expect . any ( Promise ) ,
6971 } ) ;
7072 } ) ;
7173
@@ -91,11 +93,12 @@ describe('.create()', () => {
9193 } ) ;
9294
9395 describe ( 'when not connected' , ( ) => {
94- const setupNotConnected = ( ) => setup ( {
95- local : {
96- connected$ : new BehaviorSubject ( false ) ,
97- }
98- } ) ;
96+ const setupNotConnected = ( ) =>
97+ setup ( {
98+ local : {
99+ connected$ : new BehaviorSubject ( false ) ,
100+ } ,
101+ } ) ;
99102
100103 test ( 'throws on empty log' , async ( ) => {
101104 const kit = await setupNotConnected ( ) ;
@@ -108,16 +111,16 @@ describe('.create()', () => {
108111 expect ( err ) . toEqual ( new Error ( 'EMPTY_LOG' ) ) ;
109112 }
110113 } ) ;
111-
114+
112115 test ( 'can create a new block' , async ( ) => {
113116 const kit = await setupNotConnected ( ) ;
114117 const res = await kit . local . create ( [ 'collection' ] , kit . log , kit . id ) ;
115118 expect ( res ) . toMatchObject ( {
116119 id : kit . id ,
117- remote : expect . any ( Promise )
120+ remote : expect . any ( Promise ) ,
118121 } ) ;
119122 } ) ;
120-
123+
121124 test ( 'does not store the block on remote, throws on remote sync' , async ( ) => {
122125 const kit = await setupNotConnected ( ) ;
123126 const res = await kit . local . create ( [ 'my' , 'col' ] , kit . log , kit . id ) ;
@@ -130,7 +133,7 @@ describe('.create()', () => {
130133 }
131134 expect ( kit . remote . services . blocks . stats ( ) . blocks ) . toBe ( 0 ) ;
132135 } ) ;
133-
136+
134137 test ( 'marks item as "dirty" for sync' , async ( ) => {
135138 const kit = await setupNotConnected ( ) ;
136139 const res = await kit . local . create ( [ 'my' , 'col' ] , kit . log , kit . id ) ;
@@ -168,16 +171,16 @@ describe('.create()', () => {
168171 expect ( err ) . toEqual ( new Error ( 'EMPTY_LOG' ) ) ;
169172 }
170173 } ) ;
171-
174+
172175 test ( 'can create a new block' , async ( ) => {
173176 const kit = await setupFaultyConnection ( ) ;
174177 const res = await kit . local . create ( [ 'collection' ] , kit . log , kit . id ) ;
175178 expect ( res ) . toMatchObject ( {
176179 id : kit . id ,
177- remote : expect . any ( Promise )
180+ remote : expect . any ( Promise ) ,
178181 } ) ;
179182 } ) ;
180-
183+
181184 test ( 'does not store the block on remote, throws on remote sync' , async ( ) => {
182185 const kit = await setupFaultyConnection ( ) ;
183186 const res = await kit . local . create ( [ 'my' , 'col' ] , kit . log , kit . id ) ;
@@ -190,7 +193,7 @@ describe('.create()', () => {
190193 }
191194 expect ( kit . remote . services . blocks . stats ( ) . blocks ) . toBe ( 0 ) ;
192195 } ) ;
193-
196+
194197 test ( 'marks item as "dirty" for sync' , async ( ) => {
195198 const kit = await setupFaultyConnection ( ) ;
196199 const res = await kit . local . create ( [ 'my' , 'col' ] , kit . log , kit . id ) ;
@@ -236,16 +239,16 @@ describe('.create()', () => {
236239 expect ( err ) . toEqual ( new Error ( 'EMPTY_LOG' ) ) ;
237240 }
238241 } ) ;
239-
242+
240243 test ( 'can create a new block' , async ( ) => {
241244 const kit = await setupFaultyConnection ( ) ;
242245 const res = await kit . local . create ( [ 'collection' ] , kit . log , kit . id ) ;
243246 expect ( res ) . toMatchObject ( {
244247 id : kit . id ,
245- remote : expect . any ( Promise )
248+ remote : expect . any ( Promise ) ,
246249 } ) ;
247250 } ) ;
248-
251+
249252 test ( 'does not store the block on remote, throws on remote sync' , async ( ) => {
250253 const kit = await setupFaultyConnection ( ) ;
251254 const res = await kit . local . create ( [ 'my' , 'col' ] , kit . log , kit . id ) ;
@@ -258,7 +261,7 @@ describe('.create()', () => {
258261 }
259262 expect ( kit . remote . services . blocks . stats ( ) . blocks ) . toBe ( 0 ) ;
260263 } ) ;
261-
264+
262265 test ( 'marks item as "dirty" for sync' , async ( ) => {
263266 const kit = await setupFaultyConnection ( ) ;
264267 const res = await kit . local . create ( [ 'my' , 'col' ] , kit . log , kit . id ) ;
@@ -304,16 +307,16 @@ describe('.create()', () => {
304307 expect ( err ) . toEqual ( new Error ( 'EMPTY_LOG' ) ) ;
305308 }
306309 } ) ;
307-
310+
308311 test ( 'can create a new block' , async ( ) => {
309312 const kit = await setupFaultyConnection ( ) ;
310313 const res = await kit . local . create ( [ 'collection' ] , kit . log , kit . id ) ;
311314 expect ( res ) . toMatchObject ( {
312315 id : kit . id ,
313- remote : expect . any ( Promise )
316+ remote : expect . any ( Promise ) ,
314317 } ) ;
315318 } ) ;
316-
319+
317320 test ( 'marks item as "dirty" for sync, but synchronizes over time' , async ( ) => {
318321 const kit = await setupFaultyConnection ( ) ;
319322 const res = await kit . local . create ( [ 'my' , 'col' ] , kit . log , kit . id ) ;
0 commit comments