Skip to content

Commit 79bf0fa

Browse files
committed
test(all): improve test coverage
1 parent 3e15dae commit 79bf0fa

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

src/context.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ else if (typeof global !== 'undefined') globalObj = global // eslint-disable-lin
99
else if (typeof self !== 'undefined') globalObj = self // eslint-disable-line
1010
globalObj.$nxCompileToSandbox = toSandbox
1111
globalObj.$nxClearSandbox = clearSandbox
12-
globalObj.$nxGlobals = globals
1312

1413
export function expose (...globalNames) {
1514
for (let globalName of globalNames) {

src/parser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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) {

test/compiler.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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

test/modifiers.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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
})

0 commit comments

Comments
 (0)