
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.
28 lines
809 B
JavaScript
28 lines
809 B
JavaScript
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");
|
|
})
|
|
});
|