Environment:
immutable 3.8.2
assert 1.4.1
jest 20.0.3
describe('Immutable Map / List and fromJS Examples', function() {
it('Immutable Map / List Example', function() {
const immutableObj = Immutable.Map({
property1: 'property1',
property2: Immutable.List(['Cherry']),
property3: 'property3',
propertyMap: Immutable.Map({
propertyMapProperty: 'Shoe',
}),
});
let result = immutableObj.getIn(['propertyMap', 'propertyMapProperty'])
let expectedResult = "Shoe";
assert.equal(expectedResult, result);
let immutableList = immutableObj.get('property2');
result = immutableList.get(0);
expectedResult = "Cherry";
assert.equal(expectedResult, result);
});
it('Immutable fromJS Example', function() {
const immutableObj = Immutable.fromJS({
property1: 'property1',
property2: ['Cherry'],
property3: 'property3',
propertyMap: {propertyMapProperty: "Shoe"},
});
let result = immutableObj.getIn(['propertyMap', 'propertyMapProperty'])
let expectedResult = "Shoe";
assert.equal(expectedResult, result);
let immutableList = immutableObj.get('property2');
result = immutableList.get(0);
expectedResult = "Cherry";
assert.equal(expectedResult, result);
});
});
This article helped a lot.
No comments:
Post a Comment
I appreciate your time in leaving a comment!