Skip to content

Instantly share code, notes, and snippets.

@peleteiro
Created April 2, 2017 00:33
Show Gist options
  • Save peleteiro/ecc6410f47873c4fb8b9ebe8972c95c9 to your computer and use it in GitHub Desktop.
Save peleteiro/ecc6410f47873c4fb8b9ebe8972c95c9 to your computer and use it in GitHub Desktop.
/* eslint-disable padded-blocks */
import {Record, List} from 'immutable'
import {isEqual} from 'lodash'
export class Cake extends Record({
id: null,
name: null,
}, 'Cake') {}
describe('isEqual', () => {
const cake1 = new Cake({id: 'supchocolate', name: 'Super Chocolate Cake'})
const cake2 = new Cake({name: 'Super Chocolate Cake', id: 'supchocolate'})
const listOfCakes1 = List([cake1])
const listOfCakes2 = List([cake2])
const actionOfCakes1 = {type: 'CAKES_LOADED', cakes: listOfCakes1}
const actionOfCakes2 = {type: 'CAKES_LOADED', cakes: listOfCakes2}
describe('Immutable Record', () => {
test('plain jest', () => expect(cake1).toEqual(cake2))
test('isEqual', () => expect(isEqual(cake1, cake2)).toBe(true)) // FAILS
})
describe('Immutable List of Records', () => {
test('plain jest', () => expect(listOfCakes1).toEqual(listOfCakes2))
test('isEqual', () => expect(isEqual(listOfCakes1, listOfCakes2)).toBe(true)) // FAILS
})
describe('Redux action using immutable list of records', () => {
test('plain jest', () => expect(actionOfCakes1).toEqual(actionOfCakes2))
test('isEqual', () => expect(isEqual(actionOfCakes1, actionOfCakes2)).toBe(true)) // FAILS
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment