@@ -16,17 +16,17 @@ class CustomError extends Error {
16
16
}
17
17
}
18
18
19
- describe ( 'winston-mongodb-helpers' , function ( ) {
20
- describe ( '#prepareMetaData()' , function ( ) {
21
- it ( 'should preserve Date instances' , function ( ) {
19
+ describe ( 'winston-mongodb-helpers' , function ( ) {
20
+ describe ( '#prepareMetaData()' , function ( ) {
21
+ it ( 'should preserve Date instances' , function ( ) {
22
22
const originalData = { customDate : new Date ( ) } ;
23
23
24
24
const preparedData = helpers . prepareMetaData ( originalData ) ;
25
25
26
26
assert ( preparedData . customDate instanceof Date ) ;
27
27
assert . strictEqual ( + preparedData . customDate , + originalData . customDate ) ;
28
28
} ) ;
29
- it ( 'should store Error objects' , function ( ) {
29
+ it ( 'should store Error objects' , function ( ) {
30
30
const originalData = { standardError : new Error ( 'some error' ) } ;
31
31
32
32
const preparedData = helpers . prepareMetaData ( originalData ) ;
@@ -37,9 +37,9 @@ describe('winston-mongodb-helpers', function() {
37
37
assert . strictEqual ( preparedData . standardError . name , originalData . standardError . name ) ;
38
38
assert . strictEqual ( preparedData . standardError . stack , originalData . standardError . stack ) ;
39
39
} ) ;
40
- it ( 'should store extra fields for custom Error objects' , function ( ) {
40
+ it ( 'should store extra fields for custom Error objects' , function ( ) {
41
41
const originalData = { customError : new CustomError ( ) } ;
42
-
42
+
43
43
const preparedData = helpers . prepareMetaData ( originalData ) ;
44
44
45
45
assert ( preparedData . customError instanceof Object ) ;
@@ -49,21 +49,21 @@ describe('winston-mongodb-helpers', function() {
49
49
assert . strictEqual ( preparedData . customError . stack , originalData . customError . stack ) ;
50
50
assert . strictEqual ( preparedData . customError . testField , originalData . customError . testField ) ;
51
51
} ) ;
52
- it ( 'should preserve ObjectIds' , function ( ) {
52
+ it ( 'should preserve ObjectIds' , function ( ) {
53
53
const originalData = { objectId : new ObjectID ( ) } ;
54
-
54
+
55
55
const preparedData = helpers . prepareMetaData ( originalData ) ;
56
56
57
57
assert . strictEqual ( preparedData . objectId , originalData . objectId ) ;
58
58
} ) ;
59
- it ( 'should preserve Buffers' , function ( ) {
59
+ it ( 'should preserve Buffers' , function ( ) {
60
60
const originalData = { buffer : new Buffer . from ( 'test' ) } ;
61
-
61
+
62
62
const preparedData = helpers . prepareMetaData ( originalData ) ;
63
63
64
64
assert . strictEqual ( preparedData . buffer , originalData . buffer ) ;
65
65
} ) ;
66
- it ( 'should handle objects containing all kinds of values, including arrays, nested objects and functions' , function ( ) {
66
+ it ( 'should handle objects containing all kinds of values, including arrays, nested objects and functions' , function ( ) {
67
67
const originalData = {
68
68
undefinedValue : undefined ,
69
69
nullValue : null ,
@@ -79,10 +79,10 @@ describe('winston-mongodb-helpers', function() {
79
79
80
80
const preparedData = helpers . prepareMetaData ( originalData ) ;
81
81
82
- const expected = { ...originalData , functionValue : { } }
82
+ const expected = { ...originalData , functionValue : { } } ;
83
83
assert . deepStrictEqual ( preparedData , expected ) ;
84
84
} ) ;
85
- it ( 'should handle arrays containing all kinds of values, including objects, nested arrays and functions' , function ( ) {
85
+ it ( 'should handle arrays containing all kinds of values, including objects, nested arrays and functions' , function ( ) {
86
86
const originalData = [
87
87
undefined ,
88
88
null ,
@@ -102,15 +102,15 @@ describe('winston-mongodb-helpers', function() {
102
102
expected [ expected . length - 1 ] = { } ; // function gets converted to empty object
103
103
assert . deepStrictEqual ( preparedData , expected ) ;
104
104
} ) ;
105
- it ( 'should replace dots and dollar signs in object keys' , function ( ) {
105
+ it ( 'should replace dots and dollar signs in object keys' , function ( ) {
106
106
const originalData = { 'key.with.dots' : true , '$test$' : true } ;
107
-
107
+
108
108
const preparedData = helpers . prepareMetaData ( originalData ) ;
109
109
110
110
const expected = { 'key[dot]with[dot]dots' : true , '[$]test[$]' : true } ;
111
111
assert . deepStrictEqual ( preparedData , expected ) ;
112
112
} ) ;
113
- it ( 'should break circular dependencies' , function ( ) {
113
+ it ( 'should break circular dependencies' , function ( ) {
114
114
const originalData = { } ;
115
115
originalData . nestedObjectValue = { nestedKey : originalData } ;
116
116
originalData . arrayValue = [ originalData , 'test' , { nestedKey : originalData } ] ;
@@ -124,10 +124,10 @@ describe('winston-mongodb-helpers', function() {
124
124
125
125
assert . deepStrictEqual ( preparedData , expected ) ;
126
126
} ) ;
127
- it ( 'should handle objects with null prototype' , function ( ) {
127
+ it ( 'should handle objects with null prototype' , function ( ) {
128
128
const originalData = Object . create ( null ) ;
129
129
originalData [ 'key.with.dots' ] = true ;
130
- originalData [ ' $test$' ] = true ;
130
+ originalData . $test$ = true ;
131
131
originalData . nestedObjectValue = { nestedKey : originalData } ;
132
132
originalData . arrayValue = [ originalData , 'test' , { nestedKey : originalData } ] ;
133
133
@@ -136,8 +136,8 @@ describe('winston-mongodb-helpers', function() {
136
136
const expected = {
137
137
'key[dot]with[dot]dots' : true ,
138
138
'[$]test[$]' : true ,
139
- nestedObjectValue : { nestedKey : '[Circular]' } ,
140
- arrayValue : [ '[Circular]' , 'test' , { nestedKey : '[Circular]' } ]
139
+ ' nestedObjectValue' : { nestedKey : '[Circular]' } ,
140
+ ' arrayValue' : [ '[Circular]' , 'test' , { nestedKey : '[Circular]' } ]
141
141
} ;
142
142
143
143
assert . deepStrictEqual ( preparedData , expected ) ;
0 commit comments