Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Webini/normalizr into Web…
Browse files Browse the repository at this point in the history
…ini-master
  • Loading branch information
paularmstrong committed Jun 9, 2017
2 parents 28f085b + 9a696f7 commit b25f202
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@ describe('normalize', () => {

expect(normalize({ id: '123', title: 'normalizr is great!', author: 1 }, articleEntity)).toMatchSnapshot();
});

it('can normalize object without proper object prototype inheritance', () => {
const test = { id: 1, elements: [] };
test.elements.push(Object.assign(
Object.create(null),
{
id: 18,
name: 'test'
}
));

const testEntity = new schema.Entity('test', {
elements: [ new schema.Entity('elements') ]
});

expect(() => normalize(test, testEntity)).not.toThrow();
});
});

describe('denormalize', () => {
Expand Down
5 changes: 3 additions & 2 deletions src/schemas/ImmutableUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
*/
export function isImmutable(object) {
return !!(object && (
object.hasOwnProperty('__ownerID') || // Immutable.Map
(object._map && object._map.hasOwnProperty('__ownerID')) // Immutable.Record
(typeof object.hasOwnProperty === 'function' && object.hasOwnProperty('__ownerID')) || // Immutable.Map
(object._map && typeof object._map.hasOwnProperty === 'function' &&
object._map.hasOwnProperty('__ownerID')) // Immutable.Record
));
}

Expand Down

0 comments on commit b25f202

Please sign in to comment.