File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -53,5 +53,10 @@ describe('Utils', () => {
53
53
)
54
54
) . to . equal ( false ) ;
55
55
} ) ;
56
+
57
+ it ( 'should return true for two references to the same thing' , ( ) => {
58
+ const thing = { a : 1 , b : 2 , c : undefined } ;
59
+ expect ( shallowEqual ( thing , thing ) ) . to . equal ( true ) ;
60
+ } ) ;
56
61
} ) ;
57
62
} ) ;
Original file line number Diff line number Diff line change
1
+ import { expect } from 'chai' ;
2
+ import { tassign } from './tassign' ;
3
+
4
+ describe ( 'tassign' , ( ) => {
5
+ it ( 'Returns an object with original and new values' , ( ) => {
6
+ const initial = {
7
+ a : 1 ,
8
+ b : 2 ,
9
+ } ;
10
+
11
+ const assigned = {
12
+ b : 3 ,
13
+ } ;
14
+
15
+ const expected = {
16
+ a : 1 ,
17
+ b : 3 ,
18
+ } ;
19
+
20
+ expect ( tassign ( initial , assigned ) ) . to . eql ( expected ) ;
21
+ } ) ;
22
+
23
+ it ( 'Returns a new object reference' , ( ) => {
24
+ const initial = {
25
+ a : 1 ,
26
+ b : 2 ,
27
+ } ;
28
+
29
+ const assigned = { } ;
30
+
31
+ expect ( tassign ( initial , assigned ) ) . not . to . equal ( initial ) ;
32
+ } ) ;
33
+
34
+ it ( 'Does not mutate the original object' , ( ) => {
35
+ const initial = {
36
+ a : 1 ,
37
+ b : 2 ,
38
+ } ;
39
+
40
+ const assigned = {
41
+ b : 3 ,
42
+ } ;
43
+
44
+ const expected = {
45
+ a : 1 ,
46
+ b : 2 ,
47
+ } ;
48
+
49
+ tassign ( initial , assigned ) ;
50
+ expect ( initial ) . to . eql ( expected ) ;
51
+ } ) ;
52
+ } ) ;
You can’t perform that action at this time.
0 commit comments