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
99else if ( typeof self !== 'undefined' ) globalObj = self // eslint-disable-line
1010globalObj . $nxCompileToSandbox = toSandbox
1111globalObj . $nxClearSandbox = clearSandbox
12- globalObj . $nxGlobals = globals
1312
1413export function expose ( ...globalNames ) {
1514 for ( let globalName of globalNames ) {
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ export function parseExpression (src) {
1616 filters : [ ]
1717 }
1818 for ( let i = 1 ; i < tokens . length ; i ++ ) {
19- let filterTokens = tokens [ i ] . match ( argsRegex ) || [ ]
19+ let filterTokens = tokens [ i ] . match ( argsRegex )
2020 const filterName = filterTokens . shift ( )
2121 const effect = filters . get ( filterName )
2222 if ( ! effect ) {
@@ -38,7 +38,7 @@ export function parseCode (src) {
3838 limiters : [ ]
3939 }
4040 for ( let i = 1 ; i < tokens . length ; i ++ ) {
41- const limiterTokens = tokens [ i ] . match ( argsRegex ) || [ ]
41+ const limiterTokens = tokens [ i ] . match ( argsRegex )
4242 const limiterName = limiterTokens . shift ( )
4343 const effect = limiters . get ( limiterName )
4444 if ( ! effect ) {
Original file line number Diff line number Diff line change @@ -19,9 +19,9 @@ describe('compiler', () => {
1919
2020 describe ( 'compileExpression()' , ( ) => {
2121 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 )
2525 } )
2626 } )
2727
Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ describe('context', () => {
3636 const expression = compiler . compileExpression ( 'message | slice 1 4 | capitalize' )
3737 expect ( expression ( { message : 'hello' } ) ) . to . equal ( 'ELL' )
3838 } )
39+
40+ it ( 'should throw an error on using unregistered filters' , ( ) => {
41+ expect ( ( ) => compiler . compileExpression ( 'message | unregisteredFilter' ) ) . to . throw ( Error )
42+ } )
3943 } )
4044
4145 describe ( 'limiter' , ( ) => {
@@ -134,4 +138,8 @@ describe('context', () => {
134138 expect ( context . counter ) . to . equal ( 2 )
135139 } )
136140 } )
141+
142+ it ( 'should throw an error on using unregistered limiters' , ( ) => {
143+ expect ( ( ) => compiler . compileCode ( 'return message & unregisteredLimiter' ) ) . to . throw ( Error )
144+ } )
137145} )
You can’t perform that action at this time.
0 commit comments