@@ -3,15 +3,15 @@ import { module, test } from 'qunit';
33
44import { defer } from 'rsvp' ;
55
6- import { Response } from 'miragejs ' ;
6+ import { http , HttpResponse } from 'msw ' ;
77
88import { setupApplicationTest } from 'crates-io/tests/helpers' ;
99
1010module ( 'Acceptance | publish notifications' , function ( hooks ) {
11- setupApplicationTest ( hooks ) ;
11+ setupApplicationTest ( hooks , { msw : true } ) ;
1212
1313 test ( 'unsubscribe and resubscribe' , async function ( assert ) {
14- let user = this . server . create ( 'user' ) ;
14+ let user = this . db . user . create ( ) ;
1515
1616 this . authenticateAs ( user ) ;
1717 assert . true ( user . publishNotifications ) ;
@@ -24,20 +24,22 @@ module('Acceptance | publish notifications', function (hooks) {
2424 assert . dom ( '[data-test-notifications] input[type=checkbox]' ) . isNotChecked ( ) ;
2525
2626 await click ( '[data-test-notifications] button' ) ;
27- assert . false ( user . reload ( ) . publishNotifications ) ;
27+ user = this . db . user . findFirst ( { where : { id : { equals : user . id } } } ) ;
28+ assert . false ( user . publishNotifications ) ;
2829
2930 await click ( '[data-test-notifications] input[type=checkbox]' ) ;
3031 assert . dom ( '[data-test-notifications] input[type=checkbox]' ) . isChecked ( ) ;
3132
3233 await click ( '[data-test-notifications] button' ) ;
33- assert . true ( user . reload ( ) . publishNotifications ) ;
34+ user = this . db . user . findFirst ( { where : { id : { equals : user . id } } } ) ;
35+ assert . true ( user . publishNotifications ) ;
3436 } ) ;
3537
3638 test ( 'loading and error state' , async function ( assert ) {
37- let user = this . server . create ( 'user' ) ;
39+ let user = this . db . user . create ( ) ;
3840
3941 let deferred = defer ( ) ;
40- this . server . put ( '/api/v1/users/:user_id' , deferred . promise ) ;
42+ this . worker . use ( http . put ( '/api/v1/users/:user_id' , ( ) => deferred . promise ) ) ;
4143
4244 this . authenticateAs ( user ) ;
4345 assert . true ( user . publishNotifications ) ;
@@ -52,7 +54,7 @@ module('Acceptance | publish notifications', function (hooks) {
5254 assert . dom ( '[data-test-notifications] input[type=checkbox]' ) . isDisabled ( ) ;
5355 assert . dom ( '[data-test-notifications] button' ) . isDisabled ( ) ;
5456
55- deferred . resolve ( new Response ( 500 ) ) ;
57+ deferred . resolve ( HttpResponse . json ( { } , { status : 500 } ) ) ;
5658 await clickPromise ;
5759
5860 assert
0 commit comments