@@ -18,34 +18,56 @@ const createServer = () =>
18
18
test ( 'Updates' , async t => {
19
19
const { server, address } = await createServer ( )
20
20
21
- let res = await fetch ( `${ address } /` )
22
- t . equal ( res . status , 404 )
23
-
24
- // exists and has update
25
- res = await fetch ( `${ address } /dat-land/dat-desktop/darwin/1.0.0` )
26
- t . equal ( res . status , 200 )
27
- const body = await res . json ( )
28
- t . ok ( body . name )
29
- t . match ( body . url , / - m a c \. z i p $ / )
30
- t . ok ( body . notes )
31
-
32
- // exists but no updates
33
- res = await fetch (
34
- `https://api.github.com/repos/dat-land/dat-desktop/releases?per_page=1`
35
- )
36
- const releases = await res . json ( )
37
- res = await fetch (
38
- `${ address } /dat-land/dat-desktop/darwin/${ releases [ 0 ] . name } `
39
- )
40
- t . equal ( res . status , 204 )
41
-
42
- // exists but has no releases
43
- res = await fetch ( `${ address } /juliangruber/brace-expansion/darwin/0.0.0` )
44
- t . equal ( res . status , 404 )
45
-
46
- // doesn't exist
47
- res = await fetch ( `${ address } /doesnot/exist-123123123/darwin/0.0.0` )
48
- t . equal ( res . status , 404 )
21
+ await t . test ( 'Routes' , async t => {
22
+ const res = await fetch ( `${ address } /` )
23
+ t . equal ( res . status , 404 )
24
+
25
+ await t . test ( 'exists and has update' , async t => {
26
+ const res = await fetch ( `${ address } /dat-land/dat-desktop/darwin/1.0.0` )
27
+ t . equal ( res . status , 200 )
28
+ const body = await res . json ( )
29
+ t . ok ( body . name )
30
+ t . match ( body . url , / - m a c \. z i p $ / )
31
+ t . ok ( body . notes )
32
+ } )
33
+
34
+ await t . test ( 'exists but no updates' , async t => {
35
+ let res = await fetch (
36
+ `https://api.github.com/repos/dat-land/dat-desktop/releases?per_page=1`
37
+ )
38
+ const releases = await res . json ( )
39
+ res = await fetch (
40
+ `${ address } /dat-land/dat-desktop/darwin/${ releases [ 0 ] . name } `
41
+ )
42
+ t . equal ( res . status , 204 )
43
+ } )
44
+
45
+ await t . test ( 'exists but has no releases' , async t => {
46
+ const res = await fetch (
47
+ `${ address } /juliangruber/brace-expansion/darwin/0.0.0`
48
+ )
49
+ t . equal ( res . status , 404 )
50
+ } )
51
+
52
+ await t . test ( "doesn't exist" , async t => {
53
+ const res = await fetch ( `${ address } /doesnot/exist-123123123/darwin/0.0.0` )
54
+ t . equal ( res . status , 404 )
55
+ } )
56
+ } )
57
+
58
+ await t . test ( 'Platforms' , async t => {
59
+ await t . test ( 'Darwin' , async t => {
60
+ let res = await fetch ( `${ address } /dat-land/dat-desktop/darwin/1.0.0` )
61
+ t . equal ( res . status , 200 )
62
+ let body = await res . json ( )
63
+ t . match ( body . url , / - m a c \. z i p $ / )
64
+
65
+ res = await fetch ( `${ address } /webtorrent/webtorrent-desktop/darwin/0.0.0` )
66
+ t . equal ( res . status , 200 )
67
+ body = await res . json ( )
68
+ t . match ( body . url , / - d a r w i n \. z i p $ / )
69
+ } )
70
+ } )
49
71
50
72
server . close ( )
51
73
} )
0 commit comments