forked from mgechev/codelyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
componentChangeDetectionRule.spec.ts
47 lines (44 loc) · 1.43 KB
/
componentChangeDetectionRule.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
import { assertSuccess, assertAnnotated } from './testHelper';
describe('component-change-detection', () => {
describe('invalid component change detection', () => {
it('should fail when component used without preferred change detection type', () => {
let source = `
@Component({
changeDetection: ChangeDetectionStrategy.Default
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
})
class Test {}
`;
assertAnnotated({
ruleName: 'component-change-detection',
message: 'The changeDetection value of the component "Test" should be set to ChangeDetectionStrategy.OnPush',
source
});
});
it('should fail when component change detection is not set', () => {
let source = `
@Component({
~~~~~~~~~~~~
selector: 'foo'
})
~~
class Test {}`;
assertAnnotated({
ruleName: 'component-change-detection',
message: 'The changeDetection value of the component "Test" should be set to ChangeDetectionStrategy.OnPush',
source
});
});
});
describe('valid component selector', () => {
it('should succeed when a valid change detection strategy is set on @Component', () => {
let source = `
@Component({
changeDetection: ChangeDetectionStrategy.OnPush
})
class Test {}
`;
assertSuccess('component-change-detection', source);
});
});
});