From 9f21bccb07869883edc261516272aa5e41933c78 Mon Sep 17 00:00:00 2001 From: terrykingcha Date: Wed, 27 Apr 2016 19:14:12 +0800 Subject: [PATCH] * [jsfm] fix transformer version --- src/js-framework/lib/__test__/test.js | 16 +++++++++++++++- src/js-framework/lib/app/__test__/bundle.js | 10 ++++++++-- src/js-framework/package.json | 2 +- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/js-framework/lib/__test__/test.js b/src/js-framework/lib/__test__/test.js index 307434999a..34f464236a 100644 --- a/src/js-framework/lib/__test__/test.js +++ b/src/js-framework/lib/__test__/test.js @@ -718,7 +718,7 @@ describe('test input and output', function () { delete allDocs[name] }) - it('a wrong transformer version', () => { + it('a less wrong transformer version', () => { var name = 'transformer2' var inputCode = readInput(name) var outputCode = readOutput(name) @@ -730,4 +730,18 @@ describe('test input and output', function () { framework.destroyInstance(name) delete allDocs[name] }) + + + it('a bigger wrong transformer version', () => { + var name = 'transformer3' + var inputCode = readInput(name) + var outputCode = readOutput(name) + var doc = new Document(name) + allDocs[name] = doc + + var result = framework.createInstance(name, inputCode) + expect(result).to.be.an.instanceof(Error) + framework.destroyInstance(name) + delete allDocs[name] + }) }) diff --git a/src/js-framework/lib/app/__test__/bundle.js b/src/js-framework/lib/app/__test__/bundle.js index 3074091b00..0a3bfffc00 100644 --- a/src/js-framework/lib/app/__test__/bundle.js +++ b/src/js-framework/lib/app/__test__/bundle.js @@ -186,7 +186,7 @@ describe('parsing a bundle file', () => { const ready = sinon.spy() before(() => { - global.needTransformerVersion = '~0.1' + global.needTransformerVersion = '>=0.1 <1.0' app.define('@weex-component/main', (require, exports, module) => { module.exports = { template: componentTemplate, @@ -238,12 +238,18 @@ describe('parsing a bundle file', () => { expect(task2.args[2]).to.be.equal(-1) }) - it('with a wrong transformer version', () => { + it('with a less wrong transformer version', () => { const result = app.bootstrap( '@weex-component/main', {transformerVersion: '0.0.1'}) expect(result).instanceof(Error) }) + it('with a bigger wrong transformer version', () => { + const result = app.bootstrap( + '@weex-component/main', {transformerVersion: '9.9.9'}) + expect(result).instanceof(Error) + }) + }) }) diff --git a/src/js-framework/package.json b/src/js-framework/package.json index a893e93cb9..9d2055dbe5 100644 --- a/src/js-framework/package.json +++ b/src/js-framework/package.json @@ -70,6 +70,6 @@ "webpack": "~1.12.12" }, "optionalDependencies": { - "weex-transformer": "~0.3" + "weex-transformer": ">=0.1.7 <0.4" } }