11import { currentURL } from '@ember/test-helpers' ;
22import { module , test } from 'qunit' ;
33
4+ import { http , HttpResponse } from 'msw' ;
5+
46import { setupApplicationTest } from 'crates-io/tests/helpers' ;
57
68import { visit } from '../helpers/visit-ignoring-abort' ;
79
810module ( 'Route | category' , function ( hooks ) {
9- setupApplicationTest ( hooks ) ;
11+ setupApplicationTest ( hooks , { msw : true } ) ;
1012
1113 test ( "shows an error message if the category can't be found" , async function ( assert ) {
1214 await visit ( '/categories/foo' ) ;
@@ -18,7 +20,8 @@ module('Route | category', function (hooks) {
1820 } ) ;
1921
2022 test ( 'server error causes the error page to be shown' , async function ( assert ) {
21- this . server . get ( '/api/v1/categories/:categoryId' , { } , 500 ) ;
23+ let error = HttpResponse . json ( { } , { status : 500 } ) ;
24+ this . worker . use ( http . get ( '/api/v1/categories/:categoryId' , ( ) => error ) ) ;
2225
2326 await visit ( '/categories/foo' ) ;
2427 assert . strictEqual ( currentURL ( ) , '/categories/foo' ) ;
@@ -29,7 +32,7 @@ module('Route | category', function (hooks) {
2932 } ) ;
3033
3134 test ( 'updates the search field when the categories route is accessed' , async function ( assert ) {
32- this . server . create ( 'category' , { category : 'foo' } ) ;
35+ this . db . category . create ( { category : 'foo' } ) ;
3336
3437 await visit ( '/' ) ;
3538 assert . dom ( '[data-test-search-input]' ) . hasValue ( '' ) ;
0 commit comments