File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
packages/plugin-firestore-admin/test/external Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { pokedex } from '@magnetarjs/test-utils'
2
+ import { FieldValue } from 'firebase-admin/firestore'
3
+ import { assert , expect , test } from 'vitest'
4
+ import { createMagnetarInstance } from '../helpers/createMagnetarInstance.js'
5
+ import { firestoreDeepEqual } from '../helpers/firestoreDeepEqual.js'
6
+
7
+ {
8
+ const testName = 'fieldValue increment'
9
+ test ( testName , async ( ) => {
10
+ const { pokedexModule } = await createMagnetarInstance ( testName , {
11
+ insertDocs : { 'pokedex/1' : pokedex ( 1 ) } ,
12
+ } )
13
+ await firestoreDeepEqual ( testName , 'pokedex/1' , pokedex ( 1 ) )
14
+ assert . deepEqual ( pokedexModule . doc ( '1' ) . data , pokedex ( 1 ) )
15
+
16
+ const payload = { base : { HP : FieldValue . increment ( 1 ) as any } }
17
+ try {
18
+ await pokedexModule . doc ( '1' ) . merge ( payload )
19
+ } catch ( error ) {
20
+ assert . fail ( JSON . stringify ( error ) )
21
+ }
22
+
23
+ const _pokedex = pokedexModule . doc ( '1' ) . data
24
+ const pokedexHp = _pokedex ?. base . HP as any
25
+
26
+ expect ( pokedexHp . constructor . name ) . toBe ( 'NumericIncrementTransform' )
27
+ expect ( pokedexHp . operand ) . toBe ( 1 )
28
+ } )
29
+ }
You can’t perform that action at this time.
0 commit comments