Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp isn't resolved in deep update paths #127

Open
texels opened this issue Jan 17, 2019 · 0 comments
Open

Timestamp isn't resolved in deep update paths #127

texels opened this issue Jan 17, 2019 · 0 comments

Comments

@texels
Copy link

texels commented Jan 17, 2019

When I try to put a timestamp ( via firebase's TIMESTAMP or { '.sv : 'timestamp' } object, deep objects are not resolved to the time:

Test
`
const Mock = require( 'firebase-mock' )
const { expect } = require( 'chai' )

let database = new Mock.MockFirebase()
const firebase = Mock.MockFirebaseSdk( ( path ) => {
return path ? database.child( path ) : database;
} )

const time = 10
Mock.MockFirebase.setClock( () => time )

describe( 'Firebase Mock Timestamp', () => {
beforeEach( () => {
database = new Mock.MockFirebase( null, null )
database.autoFlush( 1 )
} )

it( 'should set all timestamps', async () => {
const ts = { '.sv' : 'timestamp' }
await firebase.initializeApp().database().ref().update( { t : ts, t2 : ts, 'd/e' : ts, 'x/y/z/aa' : ts, 'a/b/c' : ts } )
// await firebase.initializeApp().database().ref().update( { "t" : { '.sv' : 'timestamp' }, "a/b/c" : { '.sv' : 'timestamp' } })
const data = database.getData()
console.log( JSON.stringify( data, null, 2 ) )
expect( data.t ).to.equal( 10 )
expect( data.t2 ).to.equal( 10 )
expect( data.d.e ).to.equal( 10 )
expect( data.x.y.z.aa ).to.equal( 10 )
expect( data.a.b.c ).to.equal( 10 )
} )
} )`

the resulting console log shows:
{ "a": { "b": { "c": { ".sv": "timestamp" } } }, "d": { "e": 10 }, "t": 10, "t2": 10, "x": { "y": { "z": { "aa": { ".sv": "timestamp" } } } } }
Expected
the a/b/c and x/y/z/aa should both be 10, and not the timestamp object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant