/
get-api-tags.spec.ts
60 lines (41 loc) 路 1.16 KB
/
get-api-tags.spec.ts
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
// std
import { deepStrictEqual, strictEqual } from 'assert';
// FoalTS
import { ApiDefineTag } from '../decorators';
import { IApiTag } from '../interfaces';
import { getApiTags } from './get-api-tags';
describe('getApiTags', () => {
const tag: IApiTag = {
name: 'tag 1'
};
describe('when tags are defined, should return them from', () => {
it('from a class.', () => {
@ApiDefineTag(tag)
class Controller {}
const actual = getApiTags(Controller);
deepStrictEqual(actual, [ tag ]);
});
it('from a class method.', () => {
class Controller {
@ApiDefineTag(tag)
foo() {}
}
const actual = getApiTags(Controller, 'foo');
deepStrictEqual(actual, [ tag ]);
});
});
describe('when no tag is defined, should return undefined from', () => {
it('from a class.', () => {
class Controller {}
const actual = getApiTags(Controller);
strictEqual(actual, undefined);
});
it('from a class method.', () => {
class Controller {
foo() {}
}
const actual = getApiTags(Controller, 'foo');
strictEqual(actual, undefined);
});
});
});