/
githubmirror
/
immutable-js
Обзор
Документация
Войти
/
githubmirror
/
immutable-js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
__tests__/utils.js
62 строки
2 KB
Julien Deniau
Add all eslint plugins
13 фев 2025, 13:45
13 фев 2025, 13:45
992ae26
Код
Авторство
О чём код?
/** * @jest-environment jsdom */ import { List, isPlainObject } from 'immutable'; describe('Utils', () => { describe('isPlainObj()', function testFunc() { const nonPlainCases = [ ['Host object', document.createElement('div')], ['bool primitive false', false], ['bool primitive true', true], ['falsy undefined', undefined], ['falsy null', null], ['Simple function', function () {}], [ 'Instance of other object', (function () { function Foo() {} return new Foo(); })(), ], ['Number primitive ', 5], ['String primitive ', 'P'], ['Number Object', Number(6)], ['Immutable.List', new List()], ['simple array', ['one']], ['Error', Error], ['Internal namespaces', Math], ['Arguments', arguments], ]; const plainCases = [ ['literal Object', {}], // eslint-disable-next-line no-object-constructor ['new Object', new Object()], ['Object.create(null)', Object.create(null)], ['nested object', { one: { prop: 'two' } }], ['constructor prop', { constructor: 'prop' }], // shadows an object's constructor ['constructor.name', { constructor: { name: 'two' } }], // shadows an object's constructor.name [ 'Fake toString', { toString: function () { return '[object Object]'; }, }, ], ]; nonPlainCases.forEach(([name, value]) => { it(`${name} returns false`, () => { expect(isPlainObject(value)).toBe(false); }); }); plainCases.forEach(([name, value]) => { it(`${name} returns true`, () => { expect(isPlainObject(value)).toBe(true); }); }); }); });