|
1 | 1 | import test from 'ava' |
2 | | -import versionCheck from '../src/index' |
3 | | -import { ReleaseDescriptor } from '../src/types' |
| 2 | +import versionCheck from '../src/check' |
| 3 | +import { CheckOptions, CheckResult } from '@github-version-checker/api' |
4 | 4 |
|
5 | 5 | if (! process.env['GITHUB_TOKEN']) { |
6 | 6 | throw new Error('No GITHUB_TOKEN specified!') |
7 | 7 | } |
8 | 8 |
|
9 | | -const opts = { |
| 9 | +const opts: CheckOptions = { |
10 | 10 | owner: 'axelrindle', |
11 | 11 | repo: 'github-version-checker', |
12 | 12 | currentVersion: '0.0.1' |
13 | 13 | } |
14 | 14 |
|
15 | 15 | test('graphql returns the same releases answer as rest', async (t) => { |
16 | | - const responseGraphql = await versionCheck(opts) as ReleaseDescriptor |
| 16 | + const responseGraphql = await versionCheck(opts) as CheckResult |
17 | 17 | t.not(responseGraphql, undefined) |
18 | 18 |
|
19 | | - const responseRest = await versionCheck({ token: false, ...opts }) as ReleaseDescriptor |
| 19 | + const responseRest = await versionCheck({ ...opts, token: false }) as CheckResult |
20 | 20 | t.not(responseRest, undefined) |
21 | 21 |
|
22 | | - t.deepEqual(responseRest, responseGraphql) |
| 22 | + t.is(responseGraphql.src, 'graphql') |
| 23 | + t.is(responseRest.src, 'rest') |
| 24 | + t.deepEqual(responseRest.update, responseGraphql.update) |
23 | 25 | }) |
24 | 26 |
|
25 | 27 | test('graphql returns the same tags answer as rest', async (t) => { |
26 | | - const responseGraphql = await versionCheck({ fetchTags: true, ...opts }) as ReleaseDescriptor |
| 28 | + const responseGraphql = await versionCheck({ ...opts, fetchTags: true }) as CheckResult |
27 | 29 | t.not(responseGraphql, undefined) |
28 | 30 |
|
29 | | - const responseRest = await versionCheck({ token: false, fetchTags: true, ...opts }) as ReleaseDescriptor |
| 31 | + const responseRest = await versionCheck({ ...opts, token: false, fetchTags: true }) as CheckResult |
30 | 32 | t.not(responseRest, undefined) |
31 | 33 |
|
32 | | - t.deepEqual(responseRest, responseGraphql) |
| 34 | + t.is(responseGraphql.src, 'graphql') |
| 35 | + t.is(responseRest.src, 'rest') |
| 36 | + t.deepEqual(responseRest.update, responseGraphql.update) |
33 | 37 | }) |
0 commit comments