samedi 1 juillet 2017

How should I test two nested immutable js data structures for deep equality?

Say I have the following nested immutable data structure:

import { Record, List } from 'immutable'

const foo = List([
        Record({
           id: 1,
           gameState: Record({})
         })
       ])

How would I test that two nested immutable js data structures are equal to each other?

test.js

import jest from 'jest'
import { Record, List } from 'immutable'

describe('test', () => {
    it('that foo equals expected', () => {
        const expected = List([
              Record({
                 id: 1,
                 gameState: Record({})
               })
             ])
        expect(foo).toEqual(expected)
    })

Aucun commentaire:

Enregistrer un commentaire