7
7
*/
8
8
9
9
import { AbsoluteSourceSpan , IdentifierKind } from '..' ;
10
+ import { runInEachFileSystem } from '../../file_system/testing' ;
10
11
import { getTemplateIdentifiers } from '../src/template' ;
11
12
import * as util from './util' ;
12
13
@@ -17,112 +18,114 @@ function bind(template: string) {
17
18
} ) ;
18
19
}
19
20
20
- describe ( 'getTemplateIdentifiers' , ( ) => {
21
- it ( 'should generate nothing in HTML-only template' , ( ) => {
22
- const refs = getTemplateIdentifiers ( bind ( '<div></div>' ) ) ;
21
+ runInEachFileSystem ( ( ) => {
22
+ describe ( 'getTemplateIdentifiers' , ( ) => {
23
+ it ( 'should generate nothing in HTML-only template' , ( ) => {
24
+ const refs = getTemplateIdentifiers ( bind ( '<div></div>' ) ) ;
23
25
24
- expect ( refs . size ) . toBe ( 0 ) ;
25
- } ) ;
26
-
27
- it ( 'should ignore comments' , ( ) => {
28
- const refs = getTemplateIdentifiers ( bind ( '<!-- {{comment}} -->' ) ) ;
29
-
30
- expect ( refs . size ) . toBe ( 0 ) ;
31
- } ) ;
32
-
33
- it ( 'should handle arbitrary whitespace' , ( ) => {
34
- const template = '<div>\n\n {{foo}}</div>' ;
35
- const refs = getTemplateIdentifiers ( bind ( template ) ) ;
36
-
37
- const [ ref ] = Array . from ( refs ) ;
38
- expect ( ref ) . toEqual ( {
39
- name : 'foo' ,
40
- kind : IdentifierKind . Property ,
41
- span : new AbsoluteSourceSpan ( 12 , 15 ) ,
26
+ expect ( refs . size ) . toBe ( 0 ) ;
42
27
} ) ;
43
- } ) ;
44
28
45
- it ( 'should ignore identifiers defined in the template' , ( ) => {
46
- const template = `
47
- <input #model />
48
- {{model.valid}}
49
- ` ;
50
- const refs = getTemplateIdentifiers ( bind ( template ) ) ;
29
+ it ( 'should ignore comments' , ( ) => {
30
+ const refs = getTemplateIdentifiers ( bind ( '<!-- {{comment}} -->' ) ) ;
51
31
52
- const refArr = Array . from ( refs ) ;
53
- const modelId = refArr . find ( ref => ref . name === 'model' ) ;
54
- expect ( modelId ) . toBeUndefined ( ) ;
55
- } ) ;
32
+ expect ( refs . size ) . toBe ( 0 ) ;
33
+ } ) ;
56
34
57
- describe ( 'generates identifiers for PropertyReads' , ( ) => {
58
- it ( 'should discover component properties' , ( ) => {
59
- const template = '{{foo}}' ;
35
+ it ( 'should handle arbitrary whitespace' , ( ) => {
36
+ const template = '<div>\n\n {{foo}}</div>' ;
60
37
const refs = getTemplateIdentifiers ( bind ( template ) ) ;
61
- expect ( refs . size ) . toBe ( 1 ) ;
62
38
63
39
const [ ref ] = Array . from ( refs ) ;
64
40
expect ( ref ) . toEqual ( {
65
41
name : 'foo' ,
66
42
kind : IdentifierKind . Property ,
67
- span : new AbsoluteSourceSpan ( 2 , 5 ) ,
43
+ span : new AbsoluteSourceSpan ( 12 , 15 ) ,
68
44
} ) ;
69
45
} ) ;
70
46
71
- it ( 'should discover nested properties' , ( ) => {
72
- const template = '<div><span>{{foo}}</span></div>' ;
47
+ it ( 'should ignore identifiers defined in the template' , ( ) => {
48
+ const template = `
49
+ <input #model />
50
+ {{model.valid}}
51
+ ` ;
73
52
const refs = getTemplateIdentifiers ( bind ( template ) ) ;
74
53
75
54
const refArr = Array . from ( refs ) ;
76
- expect ( refArr ) . toEqual ( jasmine . arrayContaining ( [ {
77
- name : 'foo' ,
78
- kind : IdentifierKind . Property ,
79
- span : new AbsoluteSourceSpan ( 13 , 16 ) ,
80
- } ] ) ) ;
55
+ const modelId = refArr . find ( ref => ref . name === 'model' ) ;
56
+ expect ( modelId ) . toBeUndefined ( ) ;
81
57
} ) ;
82
58
83
- it ( 'should ignore identifiers that are not implicitly received by the template' , ( ) => {
84
- const template = '{{foo.bar.baz}}' ;
85
- const refs = getTemplateIdentifiers ( bind ( template ) ) ;
86
- expect ( refs . size ) . toBe ( 1 ) ;
59
+ describe ( 'generates identifiers for PropertyReads' , ( ) => {
60
+ it ( 'should discover component properties' , ( ) => {
61
+ const template = '{{foo}}' ;
62
+ const refs = getTemplateIdentifiers ( bind ( template ) ) ;
63
+ expect ( refs . size ) . toBe ( 1 ) ;
64
+
65
+ const [ ref ] = Array . from ( refs ) ;
66
+ expect ( ref ) . toEqual ( {
67
+ name : 'foo' ,
68
+ kind : IdentifierKind . Property ,
69
+ span : new AbsoluteSourceSpan ( 2 , 5 ) ,
70
+ } ) ;
71
+ } ) ;
87
72
88
- const [ ref ] = Array . from ( refs ) ;
89
- expect ( ref . name ) . toBe ( 'foo' ) ;
90
- } ) ;
91
- } ) ;
73
+ it ( 'should discover nested properties' , ( ) => {
74
+ const template = '<div><span>{{foo}}</span></div>' ;
75
+ const refs = getTemplateIdentifiers ( bind ( template ) ) ;
92
76
93
- describe ( 'generates identifiers for MethodCalls' , ( ) => {
94
- it ( 'should discover component method calls' , ( ) => {
95
- const template = '{{foo()}}' ;
96
- const refs = getTemplateIdentifiers ( bind ( template ) ) ;
97
- expect ( refs . size ) . toBe ( 1 ) ;
77
+ const refArr = Array . from ( refs ) ;
78
+ expect ( refArr ) . toEqual ( jasmine . arrayContaining ( [ {
79
+ name : 'foo' ,
80
+ kind : IdentifierKind . Property ,
81
+ span : new AbsoluteSourceSpan ( 13 , 16 ) ,
82
+ } ] ) ) ;
83
+ } ) ;
98
84
99
- const [ ref ] = Array . from ( refs ) ;
100
- expect ( ref ) . toEqual ( {
101
- name : 'foo' ,
102
- kind : IdentifierKind . Method ,
103
- span : new AbsoluteSourceSpan ( 2 , 5 ) ,
85
+ it ( 'should ignore identifiers that are not implicitly received by the template' , ( ) => {
86
+ const template = '{{foo.bar.baz}}' ;
87
+ const refs = getTemplateIdentifiers ( bind ( template ) ) ;
88
+ expect ( refs . size ) . toBe ( 1 ) ;
89
+
90
+ const [ ref ] = Array . from ( refs ) ;
91
+ expect ( ref . name ) . toBe ( 'foo' ) ;
104
92
} ) ;
105
93
} ) ;
106
94
107
- it ( 'should discover nested properties' , ( ) => {
108
- const template = '<div><span>{{foo()}}</span></div>' ;
109
- const refs = getTemplateIdentifiers ( bind ( template ) ) ;
95
+ describe ( 'generates identifiers for MethodCalls' , ( ) => {
96
+ it ( 'should discover component method calls' , ( ) => {
97
+ const template = '{{foo()}}' ;
98
+ const refs = getTemplateIdentifiers ( bind ( template ) ) ;
99
+ expect ( refs . size ) . toBe ( 1 ) ;
100
+
101
+ const [ ref ] = Array . from ( refs ) ;
102
+ expect ( ref ) . toEqual ( {
103
+ name : 'foo' ,
104
+ kind : IdentifierKind . Method ,
105
+ span : new AbsoluteSourceSpan ( 2 , 5 ) ,
106
+ } ) ;
107
+ } ) ;
110
108
111
- const refArr = Array . from ( refs ) ;
112
- expect ( refArr ) . toEqual ( jasmine . arrayContaining ( [ {
113
- name : 'foo' ,
114
- kind : IdentifierKind . Method ,
115
- span : new AbsoluteSourceSpan ( 13 , 16 ) ,
116
- } ] ) ) ;
117
- } ) ;
109
+ it ( 'should discover nested properties' , ( ) => {
110
+ const template = '<div><span>{{foo()}}</span></div>' ;
111
+ const refs = getTemplateIdentifiers ( bind ( template ) ) ;
118
112
119
- it ( 'should ignore identifiers that are not implicitly received by the template' , ( ) => {
120
- const template = '{{foo().bar().baz()}}' ;
121
- const refs = getTemplateIdentifiers ( bind ( template ) ) ;
122
- expect ( refs . size ) . toBe ( 1 ) ;
113
+ const refArr = Array . from ( refs ) ;
114
+ expect ( refArr ) . toEqual ( jasmine . arrayContaining ( [ {
115
+ name : 'foo' ,
116
+ kind : IdentifierKind . Method ,
117
+ span : new AbsoluteSourceSpan ( 13 , 16 ) ,
118
+ } ] ) ) ;
119
+ } ) ;
123
120
124
- const [ ref ] = Array . from ( refs ) ;
125
- expect ( ref . name ) . toBe ( 'foo' ) ;
121
+ it ( 'should ignore identifiers that are not implicitly received by the template' , ( ) => {
122
+ const template = '{{foo().bar().baz()}}' ;
123
+ const refs = getTemplateIdentifiers ( bind ( template ) ) ;
124
+ expect ( refs . size ) . toBe ( 1 ) ;
125
+
126
+ const [ ref ] = Array . from ( refs ) ;
127
+ expect ( ref . name ) . toBe ( 'foo' ) ;
128
+ } ) ;
126
129
} ) ;
127
130
} ) ;
128
131
} ) ;
0 commit comments