@@ -118,19 +118,21 @@ describe(DBTransaction.name, () => {
118
118
} ) ;
119
119
} ) ;
120
120
await db . clear ( ) ;
121
- await expect ( withF ( [ db . transaction ( ) ] , async ( [ tran1 ] ) => {
122
- expect ( await tran1 . get ( 'hello' ) ) . toBeUndefined ( ) ;
123
- await tran1 . put ( 'hello' , 'foo' ) ;
124
- // This transaction commits, but the outside transaction will fail
125
- await withF ( [ db . transaction ( ) ] , async ( [ tran2 ] ) => {
126
- // `tran1` has not yet committed
127
- expect ( await tran2 . get ( 'hello' ) ) . toBeUndefined ( ) ;
128
- // This will cause a conflict with the external transaction
129
- await tran2 . put ( 'hello' , 'bar' ) ;
130
- // `tran2` has not yet committed
131
- expect ( await tran1 . get ( 'hello' ) ) . toBe ( 'foo' ) ;
132
- } ) ;
133
- } ) ) . rejects . toThrow ( errors . ErrorDBTransactionConflict ) ;
121
+ await expect (
122
+ withF ( [ db . transaction ( ) ] , async ( [ tran1 ] ) => {
123
+ expect ( await tran1 . get ( 'hello' ) ) . toBeUndefined ( ) ;
124
+ await tran1 . put ( 'hello' , 'foo' ) ;
125
+ // This transaction commits, but the outside transaction will fail
126
+ await withF ( [ db . transaction ( ) ] , async ( [ tran2 ] ) => {
127
+ // `tran1` has not yet committed
128
+ expect ( await tran2 . get ( 'hello' ) ) . toBeUndefined ( ) ;
129
+ // This will cause a conflict with the external transaction
130
+ await tran2 . put ( 'hello' , 'bar' ) ;
131
+ // `tran2` has not yet committed
132
+ expect ( await tran1 . get ( 'hello' ) ) . toBe ( 'foo' ) ;
133
+ } ) ;
134
+ } ) ,
135
+ ) . rejects . toThrow ( errors . ErrorDBTransactionConflict ) ;
134
136
} ) ;
135
137
test ( 'repeatable reads' , async ( ) => {
136
138
await withF ( [ db . transaction ( ) ] , async ( [ tran1 ] ) => {
@@ -146,19 +148,23 @@ describe(DBTransaction.name, () => {
146
148
} ) ;
147
149
expect ( await db . get ( 'hello' ) ) . toBe ( 'world' ) ;
148
150
await db . clear ( ) ;
149
- await expect ( db . withTransactionF ( async ( tran1 ) => {
150
- expect ( await tran1 . get ( 'hello' ) ) . toBeUndefined ( ) ;
151
- await tran1 . put ( 'hello' , 'foo' ) ;
152
- await expect ( withF ( [ db . transaction ( ) ] , async ( [ tran2 ] ) => {
153
- // `tran1` has not yet committed
154
- expect ( await tran2 . get ( 'hello' ) ) . toBeUndefined ( ) ;
155
- await tran2 . put ( 'hello' , 'bar' ) ;
156
- } ) ) . resolves . toBeUndefined ( ) ;
157
- // `tran2` is now committed
158
- // however because `foo` has been written in tran1, it stays as `foo`
159
- expect ( await tran1 . get ( 'hello' ) ) . toBe ( 'foo' ) ;
160
- // `hello` -> `foo` conflicts with `hello` -> `bar`
161
- } ) ) . rejects . toThrow ( errors . ErrorDBTransactionConflict ) ;
151
+ await expect (
152
+ db . withTransactionF ( async ( tran1 ) => {
153
+ expect ( await tran1 . get ( 'hello' ) ) . toBeUndefined ( ) ;
154
+ await tran1 . put ( 'hello' , 'foo' ) ;
155
+ await expect (
156
+ withF ( [ db . transaction ( ) ] , async ( [ tran2 ] ) => {
157
+ // `tran1` has not yet committed
158
+ expect ( await tran2 . get ( 'hello' ) ) . toBeUndefined ( ) ;
159
+ await tran2 . put ( 'hello' , 'bar' ) ;
160
+ } ) ,
161
+ ) . resolves . toBeUndefined ( ) ;
162
+ // `tran2` is now committed
163
+ // however because `foo` has been written in tran1, it stays as `foo`
164
+ expect ( await tran1 . get ( 'hello' ) ) . toBe ( 'foo' ) ;
165
+ // `hello` -> `foo` conflicts with `hello` -> `bar`
166
+ } ) ,
167
+ ) . rejects . toThrow ( errors . ErrorDBTransactionConflict ) ;
162
168
expect ( await db . get ( 'hello' ) ) . toBe ( 'bar' ) ;
163
169
} ) ;
164
170
test ( 'no phantom reads' , async ( ) => {
@@ -284,10 +290,10 @@ describe(DBTransaction.name, () => {
284
290
const results : Array < [ string , string ] > = [ ] ;
285
291
await withF ( [ db . transaction ( ) ] , async ( [ tran ] ) => {
286
292
await tran . del ( [ 'a' , 'b' ] ) ;
287
- for await ( const [ kP , v ] of tran . iterator < string > (
288
- [ 'a' ] ,
289
- { keyAsBuffer : false , valueAsBuffer : false } ,
290
- ) ) {
293
+ for await ( const [ kP , v ] of tran . iterator < string > ( [ 'a' ] , {
294
+ keyAsBuffer : false ,
295
+ valueAsBuffer : false ,
296
+ } ) ) {
291
297
results . push ( [ kP [ 0 ] as string , v ] ) ;
292
298
}
293
299
} ) ;
0 commit comments