feature(build): add nodejs-based unit test for dart transpiler.

This adds a unit test to the transpiler. Existing tests are themselves transpiled to ES5, which makes it impossible to do some kinds of assertions. For example, this will be useful to repro https://github.com/angular/angular/issues/509.
In this change, the actual issue isn't fixed. It only adds the reproduction.
It uses the jasmine test runner, since it's already used by the docs test. That uses version 1 of Jasmine, which isn't ideal, but I want to be consistent for now.
I discussed with Tobias the possibility of switching to Mocha for these nodejs-based tests, and we might do that sometime later.
This commit is contained in:
Alex Eagle 2015-02-04 14:59:12 -08:00
parent 3395624cb3
commit e20d9dd073
3 changed files with 39 additions and 7 deletions

View File

@ -434,8 +434,13 @@ gulp.task('test.js/ci', function (done) {
gulp.task('test.dart/ci', function (done) {
karma.start({configFile: __dirname + '/karma-dart.conf.js', singleRun: true, reporters: ['dots'], browsers: getBrowsersFromCLI()}, done);
});
gulp.task('test.transpiler.unittest', function (done) {
return gulp.src('tools/transpiler/unittest/**/*.js')
.pipe(jasmine())
});
gulp.task('ci', function(done) {
runSequence(
'test.transpiler.unittest',
'test.js/ci',
'test.dart/ci'
);

View File

@ -22,6 +22,7 @@
"node-uuid": "1.4.x"
},
"devDependencies": {
"angular": "1.3.5",
"bower": "^1.3.12",
"canonical-path": "0.0.2",
"del": "~1",
@ -43,15 +44,14 @@
"karma-cli": "^0.0.4",
"karma-dart": "^0.2.8",
"karma-jasmine": "^0.2.2",
"merge": "^1.2.0",
"angular": "1.3.5",
"minimatch": "^2.0.1",
"lodash": "^2.4.1",
"sprintf-js": "1.0.*",
"q": "^1.0.1",
"merge": "^1.2.0",
"minimatch": "^2.0.1",
"minimist": "1.1.x",
"protractor": "1.6.x",
"q": "^1.0.1",
"run-sequence": "^0.3.6",
"through2": "^0.6.1",
"minimist": "1.1.x"
"sprintf-js": "1.0.*",
"through2": "^0.6.1"
}
}

View File

@ -0,0 +1,27 @@
var compiler = require('../index');
// fixme: copied from top of gulpfile
var OPTIONS = {
sourceMaps: true,
annotations: true, // parse annotations
types: true, // parse types
script: false, // parse as a module
memberVariables: true, // parse class fields
outputLanguage: 'dart'
};
describe('transpile to dart', function(){
// https://github.com/angular/angular/issues/509
it('should not interpolate inside old quotes', function(){
var result = compiler.compile(OPTIONS, "test.js",
"var a = 1;" +
"var s1 = '${a}';" +
"var s2 = `${a}`;");
expect(result.js).toBe("library test;\n" +
"var a = 1;\n" +
// FIXME: this should escape the interpolation with backslash to fix the issue
"var s1 = '${a}';\n" +
"var s2 = '''${a}''';\n");
})
});