Skip to content

Commit 2ce7efa

Browse files
committed
fix -darwin.zip asset name, restructure tests
1 parent b693f39 commit 2ce7efa

File tree

2 files changed

+51
-29
lines changed

2 files changed

+51
-29
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class Updates {
7272
}
7373

7474
const assetPlatform = fileName => {
75-
if (/.*mac.*\.zip/.test(fileName)) return 'darwin'
75+
if (/.*(mac|darwin).*\.zip/.test(fileName)) return 'darwin'
7676
return false
7777
}
7878

test/index.js

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,56 @@ const createServer = () =>
1818
test('Updates', async t => {
1919
const { server, address } = await createServer()
2020

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, /-mac\.zip$/)
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, /-mac\.zip$/)
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, /-mac\.zip$/)
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, /-darwin\.zip$/)
69+
})
70+
})
4971

5072
server.close()
5173
})

0 commit comments

Comments
 (0)