@@ -22,8 +22,16 @@ const mockObjectMetadata: ObjectMetadataInterface = {
22
22
23
23
describe ( 'objectRecordChangedValues' , ( ) => {
24
24
it ( 'detects changes in scalar values correctly' , ( ) => {
25
- const oldRecord = { id : 1 , name : 'Original Name' , updatedAt : new Date ( ) } ;
26
- const newRecord = { id : 1 , name : 'Updated Name' , updatedAt : new Date ( ) } ;
25
+ const oldRecord = {
26
+ id : '74316f58-29b0-4a6a-b8fa-d2b506d5516m' ,
27
+ name : 'Original Name' ,
28
+ updatedAt : new Date ( ) . toString ( ) ,
29
+ } ;
30
+ const newRecord = {
31
+ id : '74316f58-29b0-4a6a-b8fa-d2b506d5516m' ,
32
+ name : 'Updated Name' ,
33
+ updatedAt : new Date ( ) . toString ( ) ,
34
+ } ;
27
35
28
36
const result = objectRecordChangedValues (
29
37
oldRecord ,
@@ -38,8 +46,14 @@ describe('objectRecordChangedValues', () => {
38
46
} ) ;
39
47
40
48
it ( 'ignores changes to the updatedAt field' , ( ) => {
41
- const oldRecord = { id : 1 , updatedAt : new Date ( '2020-01-01' ) } ;
42
- const newRecord = { id : 1 , updatedAt : new Date ( '2024-01-01' ) } ;
49
+ const oldRecord = {
50
+ id : '74316f58-29b0-4a6a-b8fa-d2b506d5516d' ,
51
+ updatedAt : new Date ( '2020-01-01' ) . toDateString ( ) ,
52
+ } ;
53
+ const newRecord = {
54
+ id : '74316f58-29b0-4a6a-b8fa-d2b506d5516d' ,
55
+ updatedAt : new Date ( '2024-01-01' ) . toDateString ( ) ,
56
+ } ;
43
57
44
58
const result = objectRecordChangedValues (
45
59
oldRecord ,
@@ -51,8 +65,16 @@ it('ignores changes to the updatedAt field', () => {
51
65
} ) ;
52
66
53
67
it ( 'returns an empty object when there are no changes' , ( ) => {
54
- const oldRecord = { id : 1 , name : 'Name' , value : 100 } ;
55
- const newRecord = { id : 1 , name : 'Name' , value : 100 } ;
68
+ const oldRecord = {
69
+ id : '74316f58-29b0-4a6a-b8fa-d2b506d5516k' ,
70
+ name : 'Name' ,
71
+ value : 100 ,
72
+ } ;
73
+ const newRecord = {
74
+ id : '74316f58-29b0-4a6a-b8fa-d2b506d5516k' ,
75
+ name : 'Name' ,
76
+ value : 100 ,
77
+ } ;
56
78
57
79
const result = objectRecordChangedValues (
58
80
oldRecord ,
@@ -65,17 +87,17 @@ it('returns an empty object when there are no changes', () => {
65
87
66
88
it ( 'correctly handles a mix of changed, unchanged, and special case values' , ( ) => {
67
89
const oldRecord = {
68
- id : 1 ,
90
+ id : '74316f58-29b0-4a6a-b8fa-d2b506d5516l' ,
69
91
name : 'Original' ,
70
92
status : 'active' ,
71
- updatedAt : new Date ( 2020 , 1 , 1 ) ,
93
+ updatedAt : new Date ( 2020 , 1 , 1 ) . toDateString ( ) ,
72
94
config : { theme : 'dark' } ,
73
95
} ;
74
96
const newRecord = {
75
- id : 1 ,
97
+ id : '74316f58-29b0-4a6a-b8fa-d2b506d5516l' ,
76
98
name : 'Updated' ,
77
99
status : 'active' ,
78
- updatedAt : new Date ( 2021 , 1 , 1 ) ,
100
+ updatedAt : new Date ( 2021 , 1 , 1 ) . toDateString ( ) ,
79
101
config : { theme : 'light' } ,
80
102
} ;
81
103
const expectedChanges = {
0 commit comments