@@ -50,7 +50,6 @@ describe('State changes', function() {
50
50
it ( 'Should save the final state' , function ( ) {
51
51
return this . subscription . cancel ( )
52
52
. then ( subscription => {
53
- console . log ( 'sdfsdfsdfsdd09-934-93409we09w09r0e9' , subscription )
54
53
expect ( subscription ) . to . have . property ( 'status' , 'canceled' )
55
54
} )
56
55
} )
@@ -94,7 +93,8 @@ describe('Observers', function() {
94
93
]
95
94
const observersThatRan = [ ]
96
95
97
- before ( function ( ) { observers . forEach ( observer => {
96
+ before ( function ( ) {
97
+ observers . forEach ( observer => {
98
98
// Clear out all existing observers for this test.
99
99
Subscription . clearObservers ( observer )
100
100
@@ -110,7 +110,6 @@ describe('Observers', function() {
110
110
return Subscription . create ( { status : 'active' } )
111
111
. then ( subscription => subscription . cancel ( ) )
112
112
} )
113
-
114
113
describe ( 'Cancel' , function ( ) {
115
114
observers . forEach ( observer => {
116
115
it ( `should run the ${ observer } observer` , function ( ) {
@@ -142,7 +141,7 @@ describe('Validation', function() {
142
141
return Subscription . create ( { status : 'unknown' } )
143
142
. catch ( err => {
144
143
expect ( err ) . to . have . property ( 'name' , 'ValidationError' )
145
- expect ( err ) . to . have . property ( 'message' , 'The `Subscription` instance is not valid. Details: `status` is not included in the list (value: \"unknown\").')
144
+ expect ( err . message ) . to . include ( ' `status` is not included in the list (value: \"unknown\").')
146
145
expect ( err ) . to . have . property ( 'statusCode' , 422 )
147
146
} )
148
147
} )
@@ -190,6 +189,7 @@ describe('Cache', function() {
190
189
191
190
it ( 'should create and cache a new state machine' , function ( ) {
192
191
const fsm = app . getStateMachine ( subscription )
192
+
193
193
expect ( app . locals ) . to . have . deep . property ( 'loopback-component-fsm.Subscription.id:1' , fsm )
194
194
} )
195
195
} )
@@ -224,24 +224,22 @@ describe('Cache', function() {
224
224
225
225
it ( 'should reuse an existing state machine if one is in use' , function ( done ) {
226
226
227
- // Make the subscription.cancel method take 200ms second to run.
228
- Subscription . observe ( 'fsm:oncancel' , ctx => {
229
- return Promise . delay ( 200 ) . return ( ctx )
230
- } )
227
+ // Make the subscription.cancel method take 100ms second to run.
228
+ Subscription . observe ( 'fsm:oncancel' , ctx => Promise . delay ( 100 ) . return ( ctx ) )
231
229
232
230
// Start a cancelation.
233
231
this . subscription . cancel ( )
234
- . then ( result => {
232
+ . then ( ( ) => {
235
233
expect ( app . locals ) . to . not . have . deep . property ( `loopback-component-fsm.Subscription.id:${ this . subscription . id } ` )
236
234
done ( )
237
235
} )
238
236
239
- // Start another cancel in 100ms (whilst the other is still running).
240
- Promise . delay ( 100 ) . then ( ( ) => this . subscription . cancel ( ) )
241
- . then ( ( ) => Promise . reject ( new Error ( 'Should not get this far' ) ) )
242
- . catch ( err => {
243
- expect ( err ) . to . have . property ( 'message' , 'Previous transition pending' )
244
- } )
237
+ // Start another cancel in 50ms (whilst the other is still running).
238
+ Promise . delay ( 50 ) . then ( ( ) => this . subscription . cancel ( ) )
239
+ . then ( ( ) => Promise . reject ( new Error ( 'Should not get this far' ) ) )
240
+ . catch ( err => {
241
+ expect ( err ) . to . have . property ( 'message' , 'Previous transition pending' )
242
+ } )
245
243
} )
246
244
} )
247
245
} )
0 commit comments