8000 fix template string tests in PhantomJS · lrenc/vue@c51fb54 · GitHub
[go: up one dir, main page]

Skip to content

Commit c51fb54

Browse files
committed
fix template string tests in PhantomJS
1 parent 917134d commit c51fb54

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

test/unit/specs/parsers/expression_spec.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,16 @@ describe('Expression Parser', function () {
286286
expect(res1).toBe(res2)
287287
})
288288

289-
it('ES2015 template string handling', function () {
290-
var res = expParser.parseExpression('a + `hi ${ b }` + c')
291-
expect(res.get.toString().indexOf('scope.a+`hi ${scope.b}`+scope.c') > -1).toBe(true)
292-
res = expParser.parseExpression('`hi ${ b + `${ d }` }`')
293-
expect(res.get.toString().indexOf('`hi ${scope.b+`${scope.d}`}`') > -1).toBe(true)
294-
res = expParser.parseExpression('{transform:`rotate(${x}deg)`}')
295-
expect(res.get.toString().indexOf('{transform:`rotate(${scope.x}deg)`}') > -1).toBe(true)
296-
})
289+
if (canMakeTemplateStringFunction()) {
290+
it('ES2015 template string handling', function () {
291+
var res = expParser.parseExpression('a + `hi ${ b }` + c')
292+
expect(res.get.toString().indexOf('scope.a+`hi ${scope.b}`+scope.c') > -1).toBe(true)
293+
res = expParser.parseExpression('`hi ${ b + `${ d }` }`')
294+
expect(res.get.toString().indexOf('`hi ${scope.b+`${scope.d}`}`') > -1).toBe(true)
295+
res = expParser.parseExpression('{transform:`rotate(${x}deg)`}')
296+
expect(res.get.toString().indexOf('{transform:`rotate(${scope.x}deg)`}') > -1).toBe(true)
297+
})
298+
}
297299

298300
describe('invalid expression', function () {
299301
beforeEach(function () {
@@ -319,3 +321,13 @@ describe('Expression Parser', function () {
319321
})
320322
})
321323
})
324+
325+
function canMakeTemplateStringFunction () {
326+
try {
327+
/* eslint-disable no-new-func */
328+
new Function('a', 'return `${a}`')
329+
} catch (e) {
330+
return false
331+
}
332+
return true
333+
}

0 commit comments

Comments
 (0)
0