11import { module , test } from 'qunit' ;
22
3- import { setupMirage , setupTest } from 'crates-io/tests/helpers' ;
3+ import { http , HttpResponse } from 'msw' ;
4+
5+ import { setupTest } from 'crates-io/tests/helpers' ;
6+ import setupMsw from 'crates-io/tests/helpers/setup-msw' ;
47
58module ( 'Service | Playground' , function ( hooks ) {
69 setupTest ( hooks ) ;
7- setupMirage ( hooks ) ;
10+ setupMsw ( hooks ) ;
811
912 hooks . beforeEach ( function ( ) {
1013 this . playground = this . owner . lookup ( 'service:playground' ) ;
@@ -21,14 +24,16 @@ module('Service | Playground', function (hooks) {
2124 { name : 'ansi_term' , version : '0.11.0' , id : 'ansi_term_0_11_0' } ,
2225 ] ;
2326
24- this . server . get ( 'https://play.rust-lang.org/meta/crates' , { crates } , 200 ) ;
27+ let response = HttpResponse . json ( { crates } ) ;
28+ this . worker . use ( http . get ( 'https://play.rust-lang.org/meta/crates' , ( ) => response ) ) ;
2529
2630 await this . playground . loadCratesTask . perform ( ) ;
2731 assert . deepEqual ( this . playground . crates , crates ) ;
2832 } ) ;
2933
3034 test ( 'loadCratesTask fails on HTTP error' , async function ( assert ) {
31- this . server . get ( 'https://play.rust-lang.org/meta/crates' , { } , 500 ) ;
35+ let error = HttpResponse . json ( { } , { status : 500 } ) ;
36+ this . worker . use ( http . get ( 'https://play.rust-lang.org/meta/crates' , ( ) => error ) ) ;
3237
3338 await assert . rejects ( this . playground . loadCratesTask . perform ( ) ) ;
3439 assert . notOk ( this . playground . crates ) ;
0 commit comments