-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathis_plain_object_test.js
49 lines (42 loc) · 1.04 KB
/
is_plain_object_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var Lib = require('../../../src/lib');
describe('isPlainObject', function() {
'use strict';
var isPlainObject = Lib.isPlainObject;
function A() {}
var shouldPass = [
{},
{a: 'A', B: 'b'}
];
var shouldFail = [
A,
new A(),
document,
window,
null,
undefined,
[],
new Float32Array(1),
'string',
true,
false,
NaN,
Infinity,
/foo/,
'\n',
new Array(10),
new Date(),
new RegExp('foo'),
new String('string'),
document.createElement('div')
];
shouldPass.forEach(function(obj) {
it('treats ' + JSON.stringify(obj) + ' as a plain object', function() {
expect(isPlainObject(obj)).toBe(true);
});
});
shouldFail.forEach(function(obj) {
it('treats ' + JSON.stringify(obj !== window ? obj : 'window') + ' as NOT a plain object', function() {
expect(isPlainObject(obj)).toBe(false);
});
});
});