This repository has been archived by the owner on Jul 30, 2020. It is now read-only.
/
test.js
105 lines (89 loc) · 3.29 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
'use strict'
import test from 'ava'
import fn from './'
test.serial('search', async t => {
t.timeout(300000)
const result = await fn.search('rollodeqc')
t.is(result[0].repository_url.indexOf('https://github.com/millette/'), 0)
})
test.serial('search paged', async t => {
t.timeout(300000)
const result = await fn.search({ q: 'rollodeqc', per_page: 5, raw: true })
t.is(result.body.length, 5)
t.is(result.body[0].repository_url.indexOf('https://github.com/millette/'), 0)
const result2 = await fn.search({ q: 'rollodeqc', page: 2, per_page: 5, raw: true })
t.is(result2.body.length, 5)
t.is(result2.body[0].repository_url.indexOf('https://github.com/millette/'), 0)
const result3 = await fn.search({ q: 'rollodeqc', page: 3, per_page: 5, raw: true })
t.is(result3.body.length, 5)
t.is(result3.body[0].repository_url.indexOf('https://github.com/millette/'), 0)
})
test.serial('search raw', async t => {
t.timeout(300000)
const result = await fn.search({ q: 'rollodeqc', raw: true })
t.is(result.body[0].repository_url.indexOf('https://github.com/millette/'), 0)
})
test.serial('npm got', async t => {
t.timeout(300000)
const result = await fn.platform('npm', 'got')
t.is(result.name, 'got')
t.is(result.platform, 'NPM')
t.is(result.repository_url, 'https://github.com/sindresorhus/got')
t.is(result.package_manager_url, 'https://www.npmjs.com/package/got')
})
test.serial('npm got raw', async t => {
t.timeout(300000)
const result = await fn.platform('npm', 'got', { raw: true })
const r2 = result.body
t.is(r2.name, 'got')
t.is(r2.platform, 'NPM')
t.is(r2.repository_url, 'https://github.com/sindresorhus/got')
t.is(r2.package_manager_url, 'https://www.npmjs.com/package/got')
})
test.serial('npm got dependencies (1)', async t => {
t.timeout(300000)
const result = await fn.platform.dependencies('npm', 'got', '6.3.0')
t.is(result.name, 'got') // FIXME
})
test.serial('npm got dependencies (2)', async t => {
t.timeout(300000)
const result = await fn.platform.dependencies('npm', 'got', '6.3.0', { raw: true })
t.is(result.body.name, 'got') // FIXME
})
test.serial('npm got dependents', async t => {
t.timeout(300000)
const result = await fn.platform.dependents('npm', 'got')
t.true(result.length > 5)
})
test.serial('npm got dependent_repositories', async t => {
t.timeout(300000)
const result = await fn.platform.dependent_repositories('npm', 'got')
t.true(result.length > 5)
})
test.serial('github', async t => {
t.timeout(300000)
const a = ['millette', 'rollodeqc-gh-utils']
const result = await fn.github(a[0], a[1])
t.is(result.full_name, a.join('/'))
})
test.serial('github dependencies', async t => {
t.timeout(300000)
const a = ['millette', 'rollodeqc-gh-utils']
const result = await fn.github.dependencies(a[0], a[1])
t.is(result.full_name, a.join('/'))
t.true(result.dependencies.length > 5)
})
test.serial('github projects', async t => {
t.timeout(300000)
const a = ['millette', 'rollodeqc-gh-utils']
const result = await fn.github.projects(a[0], a[1])
t.true(result.length > 0)
t.is(result[0].name, a[1])
t.is(result[0].platform, 'NPM')
})
test.serial('github projects 404', async t => {
t.timeout(300000)
const a = ['kudlaj', 'jamendo-contest']
const result = await fn.github.projects(a[0], a[1])
t.is(result.length, 0)
})