-
Notifications
You must be signed in to change notification settings - Fork 234
/
noQueriesParameterRule.spec.ts
69 lines (63 loc) · 1.96 KB
/
noQueriesParameterRule.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
61
62
63
64
65
66
67
68
69
import { Rule } from '../src/noQueriesParameterRule';
import { assertAnnotated, assertSuccess } from './testHelper';
type MetadataType = 'Component' | 'Directive';
const { FAILURE_STRING, metadata: { ruleName } } = Rule;
const metadataTypes = new Set<MetadataType>(['Component', 'Directive']);
describe(ruleName, () => {
metadataTypes.forEach(metadataType => {
describe(metadataType, () => {
describe('failure', () => {
it('should fail when "queries" is used', () => {
const source = `
@${metadataType}({
queries: {
~~~~~~~~
contentChildren: new ContentChildren(ChildDirective),
viewChildren: new ViewChildren(ChildDirective)
}
~
})
class Test {}
`;
assertAnnotated({
message: FAILURE_STRING,
ruleName,
source
});
});
it('should fail when "queries" is used', () => {
const source = `
@${metadataType}({
queries: {
~~~~~~~~
contentChild: new ContentChild(ChildDirective),
viewChild: new ViewChild(ChildDirective)
}
~
})
class Test {}
`;
assertAnnotated({ message: FAILURE_STRING, ruleName, source });
});
});
describe('success', () => {
it('should succeed when "queries" is not used', () => {
const source = `
@${metadataType}({})
class Test {}
`;
assertSuccess(ruleName, source);
});
it('should succeed when content decorators are used', () => {
const source = `
@${metadataType}({})
class Test {
@ContentChild(ChildDirective) contentChild: ChildDirective;
}
`;
assertSuccess(ruleName, source);
});
});
});
});
});