-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathapi.test.mjs
More file actions
52 lines (37 loc) · 1.58 KB
/
api.test.mjs
File metadata and controls
52 lines (37 loc) · 1.58 KB
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
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { getNodeApiLink } from '#site/util/api';
describe('getNodeApiLink', () => {
it('should return the correct API link for versions >=0.3.1 and <0.5.1', () => {
const version = '0.4.0';
const expectedLink = `https://nodejs.org/docs/${version}/api/`;
const result = getNodeApiLink(version);
assert.equal(result, expectedLink);
});
it('should return the correct URL for versions >=0.3.1 and <0.5.1', () => {
const url = getNodeApiLink('v0.4.10');
assert.ok(url.includes('/api/'));
});
it('should return the correct API link for versions >=0.1.14 and <0.3.1', () => {
const version = '0.2.0';
const expectedLink = `https://nodejs.org/docs/${version}/api.html`;
const result = getNodeApiLink(version);
assert.equal(result, expectedLink);
});
it('should return the correct API link for versions >=1.0.0 and <4.0.0', () => {
const version = '2.3.0';
const expectedLink = `https://iojs.org/dist/${version}/docs/api/`;
const result = getNodeApiLink(version);
assert.equal(result, expectedLink);
});
it('should form the correct URL for versions >=1.0.0 and <4.0.0', () => {
const url = getNodeApiLink('v1.2.3');
assert.ok(url.includes('iojs.org/dist/v1.2.3/docs/api/'));
});
it('should return the correct API link for other versions', () => {
const version = '5.0.0';
const expectedLink = `https://nodejs.org/dist/${version}/docs/api/`;
const result = getNodeApiLink(version);
assert.equal(result, expectedLink);
});
});