File tree Expand file tree Collapse file tree 4 files changed +13
-6
lines changed Expand file tree Collapse file tree 4 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,6 @@ else if (typeof global !== 'undefined') globalObj = global // eslint-disable-lin
9
9
else if ( typeof self !== 'undefined' ) globalObj = self // eslint-disable-line
10
10
globalObj . $nxCompileToSandbox = toSandbox
11
11
globalObj . $nxClearSandbox = clearSandbox
12
- globalObj . $nxGlobals = globals
13
12
14
13
export function expose ( ...globalNames ) {
15
14
for ( let globalName of globalNames ) {
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ export function parseExpression (src) {
16
16
filters : [ ]
17
17
}
18
18
for ( let i = 1 ; i < tokens . length ; i ++ ) {
19
- let filterTokens = tokens [ i ] . match ( argsRegex ) || [ ]
19
+ let filterTokens = tokens [ i ] . match ( argsRegex )
20
20
const filterName = filterTokens . shift ( )
21
21
const effect = filters . get ( filterName )
22
22
if ( ! effect ) {
@@ -38,7 +38,7 @@ export function parseCode (src) {
38
38
limiters : [ ]
39
39
}
40
40
for ( let i = 1 ; i < tokens . length ; i ++ ) {
41
- const limiterTokens = tokens [ i ] . match ( argsRegex ) || [ ]
41
+ const limiterTokens = tokens [ i ] . match ( argsRegex )
42
42
const limiterName = limiterTokens . shift ( )
43
43
const effect = limiters . get ( limiterName )
44
44
if ( ! effect ) {
Original file line number Diff line number Diff line change @@ -19,9 +19,9 @@ describe('compiler', () => {
19
19
20
20
describe ( 'compileExpression()' , ( ) => {
21
21
it ( 'should throw a TypeError on non string source argument' , ( ) => {
22
- expect ( ( ) => compiler . compileCode ( { } ) ) . to . throw ( TypeError )
23
- expect ( ( ) => compiler . compileCode ( undefined ) ) . to . throw ( TypeError )
24
- expect ( ( ) => compiler . compileCode ( 12 ) ) . to . throw ( TypeError )
22
+ expect ( ( ) => compiler . compileExpression ( { } ) ) . to . throw ( TypeError )
23
+ expect ( ( ) => compiler . compileExpression ( undefined ) ) . to . throw ( TypeError )
24
+ expect ( ( ) => compiler . compileExpression ( 12 ) ) . to . throw ( TypeError )
25
25
} )
26
26
} )
27
27
Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ describe('context', () => {
36
36
const expression = compiler . compileExpression ( 'message | slice 1 4 | capitalize' )
37
37
expect ( expression ( { message : 'hello' } ) ) . to . equal ( 'ELL' )
38
38
} )
39
+
40
+ it ( 'should throw an error on using unregistered filters' , ( ) => {
41
+ expect ( ( ) => compiler . compileExpression ( 'message | unregisteredFilter' ) ) . to . throw ( Error )
42
+ } )
39
43
} )
40
44
41
45
describe ( 'limiter' , ( ) => {
@@ -134,4 +138,8 @@ describe('context', () => {
134
138
expect ( context . counter ) . to . equal ( 2 )
135
139
} )
136
140
} )
141
+
142
+ it ( 'should throw an error on using unregistered limiters' , ( ) => {
143
+ expect ( ( ) => compiler . compileCode ( 'return message & unregisteredLimiter' ) ) . to . throw ( Error )
144
+ } )
137
145
} )
You can’t perform that action at this time.
0 commit comments