@@ -14,14 +14,14 @@ describe('HasTimestamps', () => {
14
14
fetchMock . mockResponseOnce ( async ( ) => Promise . resolve (
15
15
buildResponse ( User . factory ( )
16
16
. create ( )
17
- . only ( [ hasTimestamps . getCreatedAtColumn ( ) , hasTimestamps . getUpdatedAtColumn ( ) ] )
17
+ . only ( [ hasTimestamps . getCreatedAtName ( ) , hasTimestamps . getUpdatedAtName ( ) ] )
18
18
)
19
19
) ) ;
20
20
} ) ;
21
21
22
22
describe ( 'getCreatedAtColumn' , ( ) => {
23
23
it ( 'should return the createdAt column' , ( ) => {
24
- expect ( hasTimestamps . getCreatedAtColumn ( ) ) . toBe ( 'createdAt' ) ;
24
+ expect ( hasTimestamps . getCreatedAtName ( ) ) . toBe ( 'createdAt' ) ;
25
25
} ) ;
26
26
27
27
it ( 'should return the createdAt column correctly if overridden' , ( ) => {
@@ -30,13 +30,13 @@ describe('HasTimestamps', () => {
30
30
}
31
31
hasTimestamps = new MyUser ;
32
32
33
- expect ( hasTimestamps . getCreatedAtColumn ( ) ) . toBe ( 'myCreatedAt' ) ;
33
+ expect ( hasTimestamps . getCreatedAtName ( ) ) . toBe ( 'myCreatedAt' ) ;
34
34
} ) ;
35
35
} ) ;
36
36
37
37
describe ( 'getUpdatedAtColumn' , ( ) => {
38
38
it ( 'should return the updatedAt column' , ( ) => {
39
- expect ( hasTimestamps . getUpdatedAtColumn ( ) ) . toBe ( 'updatedAt' ) ;
39
+ expect ( hasTimestamps . getUpdatedAtName ( ) ) . toBe ( 'updatedAt' ) ;
40
40
} ) ;
41
41
42
42
it ( 'should return the updatedAt column correctly if overridden' , ( ) => {
@@ -45,7 +45,7 @@ describe('HasTimestamps', () => {
45
45
}
46
46
hasTimestamps = new MyUser ;
47
47
48
- expect ( hasTimestamps . getUpdatedAtColumn ( ) ) . toBe ( 'myUpdatedAt' ) ;
48
+ expect ( hasTimestamps . getUpdatedAtName ( ) ) . toBe ( 'myUpdatedAt' ) ;
49
49
} ) ;
50
50
} ) ;
51
51
@@ -75,14 +75,14 @@ describe('HasTimestamps', () => {
75
75
} ) ;
76
76
77
77
it ( 'should update the timestamps' , async ( ) => {
78
- const createdAt = hasTimestamps . getAttribute ( hasTimestamps . getCreatedAtColumn ( ) ) ;
79
- const updatedAt = hasTimestamps . getAttribute ( hasTimestamps . getUpdatedAtColumn ( ) ) ;
78
+ const createdAt = hasTimestamps . getAttribute ( hasTimestamps . getCreatedAtName ( ) ) ;
79
+ const updatedAt = hasTimestamps . getAttribute ( hasTimestamps . getUpdatedAtName ( ) ) ;
80
80
81
81
jest . advanceTimersByTime ( 1000 ) ;
82
82
await hasTimestamps . touch ( ) ;
83
83
84
- expect ( hasTimestamps . getAttribute ( hasTimestamps . getCreatedAtColumn ( ) ) ) . toBe ( createdAt ) ;
85
- expect ( hasTimestamps . getAttribute ( hasTimestamps . getUpdatedAtColumn ( ) ) ) . not . toBe ( updatedAt ) ;
84
+ expect ( hasTimestamps . getAttribute ( hasTimestamps . getCreatedAtName ( ) ) ) . toBe ( createdAt ) ;
85
+ expect ( hasTimestamps . getAttribute ( hasTimestamps . getUpdatedAtName ( ) ) ) . not . toBe ( updatedAt ) ;
86
86
} ) ;
87
87
88
88
it ( 'should throw an error if updated at column is not in the response' , async ( ) => {
@@ -93,7 +93,7 @@ describe('HasTimestamps', () => {
93
93
const failingFunc = jest . fn ( async ( ) => hasTimestamps . touch ( ) ) ;
94
94
95
95
await expect ( failingFunc ) . rejects . toThrow ( new InvalidArgumentException (
96
- '\'' + hasTimestamps . getUpdatedAtColumn ( ) + '\' is not found in the response model.'
96
+ '\'' + hasTimestamps . getUpdatedAtName ( ) + '\' is not found in the response model.'
97
97
) ) ;
98
98
} ) ;
99
99
@@ -141,14 +141,14 @@ describe('HasTimestamps', () => {
141
141
buildResponse ( { updated_at : new Date ( ) . toISOString ( ) , created_at : new Date ( ) . toISOString ( ) } )
142
142
) ) ;
143
143
144
- const createdAt = hasTimestamps . getAttribute ( hasTimestamps . getCreatedAtColumn ( ) ) ;
145
- const updatedAt = hasTimestamps . getAttribute ( hasTimestamps . getUpdatedAtColumn ( ) ) ;
144
+ const createdAt = hasTimestamps . getAttribute ( hasTimestamps . getCreatedAtName ( ) ) ;
145
+ const updatedAt = hasTimestamps . getAttribute ( hasTimestamps . getUpdatedAtName ( ) ) ;
146
146
147
147
jest . advanceTimersByTime ( 1000 ) ;
148
148
await hasTimestamps . freshTimestamps ( ) ;
149
149
150
- expect ( hasTimestamps . getAttribute ( hasTimestamps . getCreatedAtColumn ( ) ) ) . not . toBe ( createdAt ) ;
151
- expect ( hasTimestamps . getAttribute ( hasTimestamps . getUpdatedAtColumn ( ) ) ) . not . toBe ( updatedAt ) ;
150
+ expect ( hasTimestamps . getAttribute ( hasTimestamps . getCreatedAtName ( ) ) ) . not . toBe ( createdAt ) ;
151
+ expect ( hasTimestamps . getAttribute ( hasTimestamps . getUpdatedAtName ( ) ) ) . not . toBe ( updatedAt ) ;
152
152
} ) ;
153
153
154
154
it ( 'should return itself instead of new instance' , async ( ) => {
@@ -166,7 +166,7 @@ describe('HasTimestamps', () => {
166
166
const failingFunc = jest . fn ( async ( ) => hasTimestamps . freshTimestamps ( ) ) ;
167
167
168
168
await expect ( failingFunc ) . rejects . toThrow ( new InvalidArgumentException (
169
- '\'' + hasTimestamps . getCreatedAtColumn ( ) + '\' is not found in the response model.'
169
+ '\'' + hasTimestamps . getCreatedAtName ( ) + '\' is not found in the response model.'
170
170
) ) ;
171
171
} ) ;
172
172
@@ -178,7 +178,7 @@ describe('HasTimestamps', () => {
178
178
const failingFunc = jest . fn ( async ( ) => hasTimestamps . freshTimestamps ( ) ) ;
179
179
180
180
await expect ( failingFunc ) . rejects . toThrow ( new InvalidArgumentException (
181
- '\'' + hasTimestamps . getUpdatedAtColumn ( ) + '\' is not found in the response model.'
181
+ '\'' + hasTimestamps . getUpdatedAtName ( ) + '\' is not found in the response model.'
182
182
) ) ;
183
183
} ) ;
184
184
0 commit comments