fix(specs): fix util specs

This commit is contained in:
Evan Morikawa 2017-02-09 19:05:19 -05:00
parent c3d2d0563f
commit ceaad6b13c
2 changed files with 7 additions and 5 deletions

View file

@ -23,14 +23,16 @@ describe 'Utils', ->
@testThread = new Thread
id: 'local-1'
accountId: '1'
pluginMetadata: []
isSearchIndexed: false
participants: [
new Contact(id: 'local-a', name: 'Juan', email:'juan@nylas.com', accountId: '1'),
new Contact(id: 'local-b', name: 'Ben', email:'ben@nylas.com', accountId: '1')
new Contact(id: 'local-a', name: 'Juan', email:'juan@nylas.com', accountId: '1', isSearchIndexed: false),
new Contact(id: 'local-b', name: 'Ben', email:'ben@nylas.com', accountId: '1', isSearchIndexed: false)
]
subject: 'Test 1234'
it "should serialize and de-serialize models correctly", ->
expectedString = '[{"client_id":"local-1","account_id":"1","metadata":[],"subject":"Test 1234","participants":[{"client_id":"local-a","account_id":"1","name":"Juan","email":"juan@nylas.com","thirdPartyData":{},"id":"local-a"},{"client_id":"local-b","account_id":"1","name":"Ben","email":"ben@nylas.com","thirdPartyData":{},"id":"local-b"}],"in_all_mail":true,"id":"local-1","__constructorName":"Thread"}]'
expectedString = '[{"client_id":"local-1","account_id":"1","metadata":[],"subject":"Test 1234","participants":[{"client_id":"local-a","account_id":"1","name":"Juan","email":"juan@nylas.com","thirdPartyData":{},"is_search_indexed":false,"id":"local-a"},{"client_id":"local-b","account_id":"1","name":"Ben","email":"ben@nylas.com","thirdPartyData":{},"is_search_indexed":false,"id":"local-b"}],"in_all_mail":true,"is_search_indexed":false,"id":"local-1","__constructorName":"Thread"}]'
jsonString = JSON.stringify([@testThread], Utils.registeredObjectReplacer)
expect(jsonString).toEqual(expectedString)
@ -40,7 +42,7 @@ describe 'Utils', ->
it "should re-inflate Models in places they're not explicitly declared types", ->
b = new JSONBlob({id: "ThreadsToProcess", json: [@testThread]})
jsonString = JSON.stringify(b, Utils.registeredObjectReplacer)
expectedString = '{"client_id":"ThreadsToProcess","server_id":"ThreadsToProcess","json":[{"client_id":"local-1","account_id":"1","metadata":[],"subject":"Test 1234","participants":[{"client_id":"local-a","account_id":"1","name":"Juan","email":"juan@nylas.com","thirdPartyData":{},"id":"local-a"},{"client_id":"local-b","account_id":"1","name":"Ben","email":"ben@nylas.com","thirdPartyData":{},"id":"local-b"}],"in_all_mail":true,"id":"local-1","__constructorName":"Thread"}],"id":"ThreadsToProcess","__constructorName":"JSONBlob"}'
expectedString = '{"client_id":"ThreadsToProcess","server_id":"ThreadsToProcess","json":[{"client_id":"local-1","account_id":"1","metadata":[],"subject":"Test 1234","participants":[{"client_id":"local-a","account_id":"1","name":"Juan","email":"juan@nylas.com","thirdPartyData":{},"is_search_indexed":false,"id":"local-a"},{"client_id":"local-b","account_id":"1","name":"Ben","email":"ben@nylas.com","thirdPartyData":{},"is_search_indexed":false,"id":"local-b"}],"in_all_mail":true,"is_search_indexed":false,"id":"local-1","__constructorName":"Thread"}],"id":"ThreadsToProcess","__constructorName":"JSONBlob"}'
expect(jsonString).toEqual(expectedString)
revived = JSON.parse(jsonString, Utils.registeredObjectReviver)

2
src/K2

@ -1 +1 @@
Subproject commit 590a4499fea6bece4ef5da40ca8f1b4d74ba72f5
Subproject commit 3390bc0783d7f17906a6884e4d757876a337506f