1
1
import { module , test } from 'qunit' ;
2
2
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' ;
4
7
5
8
module ( 'Service | Playground' , function ( hooks ) {
6
9
setupTest ( hooks ) ;
7
- setupMirage ( hooks ) ;
10
+ setupMsw ( hooks ) ;
8
11
9
12
hooks . beforeEach ( function ( ) {
10
13
this . playground = this . owner . lookup ( 'service:playground' ) ;
@@ -21,14 +24,16 @@ module('Service | Playground', function (hooks) {
21
24
{ name : 'ansi_term' , version : '0.11.0' , id : 'ansi_term_0_11_0' } ,
22
25
] ;
23
26
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 ) ) ;
25
29
26
30
await this . playground . loadCratesTask . perform ( ) ;
27
31
assert . deepEqual ( this . playground . crates , crates ) ;
28
32
} ) ;
29
33
30
34
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 ) ) ;
32
37
33
38
await assert . rejects ( this . playground . loadCratesTask . perform ( ) ) ;
34
39
assert . notOk ( this . playground . crates ) ;
0 commit comments