1
1
import { visit } from '@ember/test-helpers' ;
2
+ import { Response } from 'miragejs' ;
2
3
import { module , test } from 'qunit' ;
3
4
4
5
import { setupApplicationTest } from 'cargo/tests/helpers' ;
@@ -18,7 +19,7 @@ module('Route | crate.version | docs link', function (hooks) {
18
19
let crate = this . server . create ( 'crate' , { name : 'foo' } ) ;
19
20
this . server . create ( 'version' , { crate, num : '1.0.0' } ) ;
20
21
21
- this . server . get ( 'https://docs.rs/crate/:crate/:version/builds .json' , [ ] ) ;
22
+ this . server . get ( 'https://docs.rs/crate/:crate/:version/status .json' , 'not found' , 404 ) ;
22
23
23
24
await visit ( '/crates/foo' ) ;
24
25
assert . dom ( '[data-test-docs-link] a' ) . doesNotExist ( ) ;
@@ -28,16 +29,10 @@ module('Route | crate.version | docs link', function (hooks) {
28
29
let crate = this . server . create ( 'crate' , { name : 'foo' } ) ;
29
30
this . server . create ( 'version' , { crate, num : '1.0.0' } ) ;
30
31
31
- this . server . get ( 'https://docs.rs/crate/:crate/:version/builds.json' , [
32
- {
33
- id : 42 ,
34
- rustc_version : 'rustc 1.50.0-nightly (1c389ffef 2020-11-24)' ,
35
- docsrs_version : 'docsrs 0.6.0 (31c864e 2020-11-22)' ,
36
- build_status : true ,
37
- build_time : '2020-12-06T09:04:36.610302Z' ,
38
- output : null ,
39
- } ,
40
- ] ) ;
32
+ this . server . get ( 'https://docs.rs/crate/:crate/:version/status.json' , {
33
+ docs_status : true ,
34
+ version : '1.0.0' ,
35
+ } ) ;
41
36
42
37
await visit ( '/crates/foo' ) ;
43
38
assert . dom ( '[data-test-docs-link] a' ) . hasAttribute ( 'href' , 'https://docs.rs/foo/1.0.0' ) ;
@@ -47,7 +42,7 @@ module('Route | crate.version | docs link', function (hooks) {
47
42
let crate = this . server . create ( 'crate' , { name : 'foo' , documentation : 'https://docs.rs/foo/0.6.2' } ) ;
48
43
this . server . create ( 'version' , { crate, num : '1.0.0' } ) ;
49
44
50
- this . server . get ( 'https://docs.rs/crate/:crate/:version/builds .json' , [ ] ) ;
45
+ this . server . get ( 'https://docs.rs/crate/:crate/:version/status .json' , 'not found' , 404 ) ;
51
46
52
47
await visit ( '/crates/foo' ) ;
53
48
assert . dom ( '[data-test-docs-link] a' ) . hasAttribute ( 'href' , 'https://docs.rs/foo/0.6.2' ) ;
@@ -57,16 +52,10 @@ module('Route | crate.version | docs link', function (hooks) {
57
52
let crate = this . server . create ( 'crate' , { name : 'foo' , documentation : 'https://docs.rs/foo/0.6.2' } ) ;
58
53
this . server . create ( 'version' , { crate, num : '1.0.0' } ) ;
59
54
60
- this . server . get ( 'https://docs.rs/crate/:crate/:version/builds.json' , [
61
- {
62
- id : 42 ,
63
- rustc_version : 'rustc 1.50.0-nightly (1c389ffef 2020-11-24)' ,
64
- docsrs_version : 'docsrs 0.6.0 (31c864e 2020-11-22)' ,
65
- build_status : true ,
66
- build_time : '2020-12-06T09:04:36.610302Z' ,
67
- output : null ,
68
- } ,
69
- ] ) ;
55
+ this . server . get ( 'https://docs.rs/crate/:crate/:version/status.json' , {
56
+ docs_status : true ,
57
+ version : '1.0.0' ,
58
+ } ) ;
70
59
71
60
await visit ( '/crates/foo' ) ;
72
61
assert . dom ( '[data-test-docs-link] a' ) . hasAttribute ( 'href' , 'https://docs.rs/foo/1.0.0' ) ;
@@ -76,27 +65,17 @@ module('Route | crate.version | docs link', function (hooks) {
76
65
let crate = this . server . create ( 'crate' , { name : 'foo' , documentation : 'https://docs.rs/foo/0.6.2' } ) ;
77
66
this . server . create ( 'version' , { crate, num : '1.0.0' } ) ;
78
67
79
- this . server . get ( 'https://docs.rs/crate/:crate/:version/builds .json' , { } , 500 ) ;
68
+ this . server . get ( 'https://docs.rs/crate/:crate/:version/status .json' , 'error' , 500 ) ;
80
69
81
70
await visit ( '/crates/foo' ) ;
82
71
assert . dom ( '[data-test-docs-link] a' ) . hasAttribute ( 'href' , 'https://docs.rs/foo/0.6.2' ) ;
83
72
} ) ;
84
73
85
- test ( 'null builds in docs.rs responses are ignored' , async function ( assert ) {
74
+ test ( 'empty docs.rs responses are ignored' , async function ( assert ) {
86
75
let crate = this . server . create ( 'crate' , { name : 'foo' , documentation : 'https://docs.rs/foo/0.6.2' } ) ;
87
76
this . server . create ( 'version' , { crate, num : '0.6.2' } ) ;
88
77
89
- this . server . get ( 'https://docs.rs/crate/:crate/:version/builds.json' , [ null ] ) ;
90
-
91
- await visit ( '/crates/foo' ) ;
92
- assert . dom ( '[data-test-docs-link] a' ) . hasAttribute ( 'href' , 'https://docs.rs/foo/0.6.2' ) ;
93
- } ) ;
94
-
95
- test ( 'empty arrays in docs.rs responses are ignored' , async function ( assert ) {
96
- let crate = this . server . create ( 'crate' , { name : 'foo' , documentation : 'https://docs.rs/foo/0.6.2' } ) ;
97
- this . server . create ( 'version' , { crate, num : '0.6.2' } ) ;
98
-
99
- this . server . get ( 'https://docs.rs/crate/:crate/:version/builds.json' , [ ] ) ;
78
+ this . server . get ( 'https://docs.rs/crate/:crate/:version/status.json' , { } ) ;
100
79
101
80
await visit ( '/crates/foo' ) ;
102
81
assert . dom ( '[data-test-docs-link] a' ) . hasAttribute ( 'href' , 'https://docs.rs/foo/0.6.2' ) ;
0 commit comments