1
- const test = require ( "ava" ) ;
1
+ const assert = require ( "node:assert/strict" )
2
+ const test = require ( "node:test" ) ;
2
3
const { isPlainObject } = require ( "../" ) ;
3
4
5
+
4
6
test ( "isPlainObject" , ( t ) => {
5
- t . is ( isPlainObject ( null ) , false ) ;
6
- t . is ( isPlainObject ( undefined ) , false ) ;
7
- t . is ( isPlainObject ( 1 ) , false ) ;
8
- t . is ( isPlainObject ( true ) , false ) ;
9
- t . is ( isPlainObject ( false ) , false ) ;
10
- t . is ( isPlainObject ( "string" ) , false ) ;
11
- t . is ( isPlainObject ( [ ] ) , false ) ;
12
- t . is ( isPlainObject ( Symbol ( "a" ) ) , false ) ;
13
- t . is (
7
+ assert . equal ( isPlainObject ( null ) , false ) ;
8
+ assert . equal ( isPlainObject ( undefined ) , false ) ;
9
+ assert . equal ( isPlainObject ( 1 ) , false ) ;
10
+ assert . equal ( isPlainObject ( true ) , false ) ;
11
+ assert . equal ( isPlainObject ( false ) , false ) ;
12
+ assert . equal ( isPlainObject ( "string" ) , false ) ;
13
+ assert . equal ( isPlainObject ( [ ] ) , false ) ;
14
+ assert . equal ( isPlainObject ( Symbol ( "a" ) ) , false ) ;
15
+ assert . equal (
14
16
isPlainObject ( function ( ) { } ) ,
15
17
false
16
18
) ;
17
19
} ) ;
18
20
19
21
// https://github.com/lodash/lodash/blob/ddfd9b11a0126db2302cb70ec9973b66baec0975/test/test.js#L11447
20
22
// Notably, did not include the test for DOM Elements.
21
- test ( "Test from lodash.isPlainObject " , ( t ) => {
22
- t . is ( isPlainObject ( { } ) , true ) ;
23
- t . is ( isPlainObject ( { a : 1 } ) , true ) ;
23
+ test ( "Test from lodash.itPlainObject " , ( t ) => {
24
+ assert . equal ( isPlainObject ( { } ) , true ) ;
25
+ assert . equal ( isPlainObject ( { a : 1 } ) , true ) ;
24
26
25
27
function Foo ( a ) {
26
28
this . a = 1 ;
27
29
}
28
30
29
- t . is ( isPlainObject ( { constructor : Foo } ) , true ) ;
30
- t . is ( isPlainObject ( [ 1 , 2 , 3 ] ) , false ) ;
31
- t . is ( isPlainObject ( new Foo ( 1 ) ) , false ) ;
31
+ assert . equal ( isPlainObject ( { constructor : Foo } ) , true ) ;
32
+ assert . equal ( isPlainObject ( [ 1 , 2 , 3 ] ) , false ) ;
33
+ assert . equal ( isPlainObject ( new Foo ( 1 ) ) , false ) ;
32
34
} ) ;
33
35
34
- test ( "Test from lodash.isPlainObject : should return `true` for objects with a `[[Prototype]]` of `null`" , ( t ) => {
36
+ test ( "Test from lodash.itPlainObject : should return `true` for objects with a `[[Prototype]]` of `null`" , ( t ) => {
35
37
let obj = Object . create ( null ) ;
36
- t . is ( isPlainObject ( obj ) , true ) ;
38
+ assert . equal ( isPlainObject ( obj ) , true ) ;
37
39
38
40
obj . constructor = Object . prototype . constructor ;
39
- t . is ( isPlainObject ( obj ) , true ) ;
41
+ assert . equal ( isPlainObject ( obj ) , true ) ;
40
42
} ) ;
41
43
42
- test ( "Test from lodash.isPlainObject : should return `true` for objects with a `valueOf` property" , ( t ) => {
43
- t . is ( isPlainObject ( { valueOf : 0 } ) , true ) ;
44
+ test ( "Test from lodash.itPlainObject : should return `true` for objects with a `valueOf` property" , ( t ) => {
45
+ assert . equal ( isPlainObject ( { valueOf : 0 } ) , true ) ;
44
46
} ) ;
45
47
46
- test ( "Test from lodash.isPlainObject : should return `true` for objects with a writable `Symbol.toStringTag` property" , ( t ) => {
48
+ test ( "Test from lodash.itPlainObject : should return `true` for objects with a writable `Symbol.toStringTag` property" , ( t ) => {
47
49
let obj = { } ;
48
50
obj [ Symbol . toStringTag ] = "X" ;
49
51
50
- t . is ( isPlainObject ( obj ) , true ) ;
52
+ assert . equal ( isPlainObject ( obj ) , true ) ;
51
53
} ) ;
52
54
53
- test ( "Test from lodash.isPlainObject : should return `false` for objects with a custom `[[Prototype]]`" , ( t ) => {
55
+ test ( "Test from lodash.itPlainObject : should return `false` for objects with a custom `[[Prototype]]`" , ( t ) => {
54
56
let obj = Object . create ( { a : 1 } ) ;
55
- t . is ( isPlainObject ( obj ) , false ) ;
57
+ assert . equal ( isPlainObject ( obj ) , false ) ;
56
58
} ) ;
57
59
58
- test ( "Test from lodash.isPlainObject (modified): should return `false` for non-Object objects" , ( t ) => {
59
- t . is ( isPlainObject ( arguments ) , true ) ; // WARNING: lodash was false
60
- t . is ( isPlainObject ( Error ) , false ) ;
61
- t . is ( isPlainObject ( Math ) , true ) ; // WARNING: lodash was false
60
+ test ( "Test from lodash.itPlainObject (modified): should return `false` for non-Object objects" , ( t ) => {
61
+ assert . equal ( isPlainObject ( arguments ) , true ) ; // WARNING: lodash was false
62
+ assert . equal ( isPlainObject ( Error ) , false ) ;
63
+ assert . equal ( isPlainObject ( Math ) , true ) ; // WARNING: lodash was false
62
64
} ) ;
63
65
64
- test ( "Test from lodash.isPlainObject : should return `false` for non-objects" , ( t ) => {
65
- t . is ( isPlainObject ( true ) , false ) ;
66
- t . is ( isPlainObject ( "a" ) , false ) ;
67
- t . is ( isPlainObject ( Symbol ( "a" ) ) , false ) ;
66
+ test ( "Test from lodash.itPlainObject : should return `false` for non-objects" , ( t ) => {
67
+ assert . equal ( isPlainObject ( true ) , false ) ;
68
+ assert . equal ( isPlainObject ( "a" ) , false ) ;
69
+ assert . equal ( isPlainObject ( Symbol ( "a" ) ) , false ) ;
68
70
} ) ;
69
71
70
- test ( "Test from lodash.isPlainObject (modified): should return `true` for objects with a read-only `Symbol.toStringTag` property" , ( t ) => {
72
+ test ( "Test from lodash.itPlainObject (modified): should return `true` for objects with a read-only `Symbol.toStringTag` property" , ( t ) => {
71
73
var object = { } ;
72
74
Object . defineProperty ( object , Symbol . toStringTag , {
73
75
configurable : true ,
@@ -76,5 +78,5 @@ test("Test from lodash.isPlainObject (modified): should return `true` for object
76
78
value : "X" ,
77
79
} ) ;
78
80
79
- t . is ( isPlainObject ( object ) , true ) ; // WARNING: lodash was false
81
+ assert . equal ( isPlainObject ( object ) , true ) ; // WARNING: lodash was false
80
82
} ) ;
0 commit comments