8
8
import * as vscode from 'vscode' ;
9
9
import { DocumentUri , TextDocument } from 'vscode-languageserver-textdocument' ;
10
10
11
- import { isInsideComponentDecorator , isInsideInlineTemplateRegion } from '../embedded_support' ;
11
+ import { isNotTypescriptOrInsideComponentDecorator } from '../embedded_support' ;
12
12
13
13
describe ( 'embedded language support' , ( ) => {
14
- describe ( 'isInsideInlineTemplateRegion' , ( ) => {
15
- it ( 'empty file' , ( ) => {
16
- test ( '¦' , isInsideInlineTemplateRegion , false ) ;
17
- } ) ;
18
-
19
- it ( 'just after template' , ( ) => {
20
- test ( `const foo = {template: '<div></div>'¦}` , isInsideInlineTemplateRegion , false ) ;
21
- } ) ;
22
-
23
- it ( 'just before template' , ( ) => {
24
- // Note that while it seems that this should be `false`, we should still consider this inside
25
- // the string because the visual mode of vim appears to have a position on top of the open
26
- // quote while the cursor position is before it.
27
- test ( `const foo = {template: ¦'<div></div>'}` , isInsideInlineTemplateRegion , true ) ;
28
- } ) ;
29
-
30
- it ( 'two spaces before template' , ( ) => {
31
- test ( `const foo = {template:¦ '<div></div>'}` , isInsideInlineTemplateRegion , false ) ;
32
- } ) ;
33
-
34
- it ( 'at beginning of template' , ( ) => {
35
- test ( `const foo = {template: '¦<div></div>'}` , isInsideInlineTemplateRegion , true ) ;
36
- } ) ;
37
-
38
- it ( 'at end of template' , ( ) => {
39
- test ( `const foo = {template: '<div></div>¦'}` , isInsideInlineTemplateRegion , true ) ;
40
- } ) ;
41
-
42
- xit ( 'works for inline templates after a template string' , ( ) => {
43
- test (
44
- 'const x = `${""}`;\n' +
45
- 'const foo = {template: `hello ¦world`}' ,
46
- isInsideInlineTemplateRegion , true ) ;
47
- } ) ;
48
-
49
- it ( 'works for inline templates after a tagged template string inside tagged template string' ,
50
- ( ) => {
51
- test (
52
- 'const x = `${`${""}`}`;\n' +
53
- 'const foo = {template: `hello ¦world`}' ,
54
- isInsideInlineTemplateRegion , true ) ;
55
- } ) ;
56
- } ) ;
57
-
58
14
describe ( 'isInsideAngularContext' , ( ) => {
59
15
it ( 'empty file' , ( ) => {
60
- test ( '¦' , isInsideComponentDecorator , false ) ;
16
+ test ( '¦' , isNotTypescriptOrInsideComponentDecorator , false ) ;
61
17
} ) ;
62
18
63
19
it ( 'just after template' , ( ) => {
64
- test ( `const foo = {template: '<div></div>'¦}` , isInsideComponentDecorator , false ) ;
20
+ test (
21
+ `const foo = {template: '<div></div>'¦}` , isNotTypescriptOrInsideComponentDecorator ,
22
+ false ) ;
65
23
} ) ;
66
24
67
25
it ( 'inside template' , ( ) => {
68
- test ( `const foo = {template: '<div>¦</div>'}` , isInsideComponentDecorator , true ) ;
26
+ test (
27
+ `const foo = {template: '<div>¦</div>'}` , isNotTypescriptOrInsideComponentDecorator ,
28
+ true ) ;
69
29
} ) ;
70
30
71
31
it ( 'just after templateUrl' , ( ) => {
72
- test ( `const foo = {templateUrl: './abc.html'¦}` , isInsideComponentDecorator , false ) ;
32
+ test (
33
+ `const foo = {templateUrl: './abc.html'¦}` , isNotTypescriptOrInsideComponentDecorator ,
34
+ false ) ;
73
35
} ) ;
74
36
75
37
it ( 'inside templateUrl' , ( ) => {
76
- test ( `const foo = {templateUrl: './abc¦.html'}` , isInsideComponentDecorator , true ) ;
38
+ test (
39
+ `const foo = {templateUrl: './abc¦.html'}` , isNotTypescriptOrInsideComponentDecorator ,
40
+ true ) ;
77
41
} ) ;
78
42
79
43
it ( 'just after styleUrls' , ( ) => {
80
- test ( `const foo = {styleUrls: ['./abc.css']¦}` , isInsideComponentDecorator , false ) ;
44
+ test (
45
+ `const foo = {styleUrls: ['./abc.css']¦}` , isNotTypescriptOrInsideComponentDecorator ,
46
+ false ) ;
81
47
} ) ;
82
48
83
49
it ( 'inside first item of styleUrls' , ( ) => {
84
- test ( `const foo = {styleUrls: ['./abc.c¦ss', 'def.css']}` , isInsideComponentDecorator , true ) ;
50
+ test (
51
+ `const foo = {styleUrls: ['./abc.c¦ss', 'def.css']}` ,
52
+ isNotTypescriptOrInsideComponentDecorator , true ) ;
85
53
} ) ;
86
54
87
55
it ( 'inside second item of styleUrls' , ( ) => {
88
- test ( `const foo = {styleUrls: ['./abc.css', 'def¦.css']}` , isInsideComponentDecorator , true ) ;
56
+ test (
57
+ `const foo = {styleUrls: ['./abc.css', 'def¦.css']}` ,
58
+ isNotTypescriptOrInsideComponentDecorator , true ) ;
89
59
} ) ;
90
60
91
61
it ( 'inside second item of styleUrls, when first is complicated function' , ( ) => {
92
62
test (
93
63
`const foo = {styleUrls: [getCss({strict: true, dirs: ['apple', 'banana']}), 'def¦.css']}` ,
94
- isInsideComponentDecorator , true ) ;
64
+ isNotTypescriptOrInsideComponentDecorator , true ) ;
95
65
} ) ;
96
66
97
67
it ( 'inside non-string item of styleUrls' , ( ) => {
98
68
test (
99
69
`const foo = {styleUrls: [getCss({strict: true¦, dirs: ['apple', 'banana']}), 'def.css']}` ,
100
- isInsideComponentDecorator , false ) ;
70
+ isNotTypescriptOrInsideComponentDecorator , false ) ;
101
71
} ) ;
102
72
} ) ;
103
73
} ) ;
@@ -129,4 +99,4 @@ function extractCursorInfo(textWithCursor: string): {cursor: number, text: strin
129
99
cursor,
130
100
text : textWithCursor . substr ( 0 , cursor ) + textWithCursor . substr ( cursor + 1 ) ,
131
101
} ;
132
- }
102
+ }
0 commit comments