reactjs - Confusion after setting a property of a Map -


i'm reading , practicing tutorial: http://teropa.info/blog/2015/09/10/full-stack-redux-tutorial.html couldn't reducer tests passed. made new test find out reason.

here's test.js(mocha chai):

import {expect} 'chai'; import {list, map, fromjs} 'immutable';  describe('set', () => {   it('sets map\'s property', () => {     const state = map();     const action = {type: 'set_entries', entries: ['trainspotting']};     const nextstate = state.set('entries', action.entries);      /*     expect(nextstate).to.equal(map({       entries: ['trainspotting']     }));     */     expect(nextstate).to.equal(fromjs({       entries: ['trainspotting']     }));   }); }); 

either use map or fromjs, test doesn't pass

if choose "map", shows:

  assertionerror: expected 'map { "entries": trainspotting }' equal 'map { "entries": trainspotting }'   + expected - actual 

if choose "fromjs", shows:

  assertionerror: expected 'map { "entries": trainspotting }' equal 'map { "entries": list [ "trainspotting" ] }'   + expected - actual    -map { "entries": trainspotting }   +map { "entries": list [ "trainspotting" ] } 

it's confusing. how make work?

did try

const nextstate = state.set('entries', list(action.entries)); 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo