2015-08-28 14:45:39 -04:00
|
|
|
import {
|
|
|
|
ddescribe,
|
|
|
|
describe,
|
|
|
|
xdescribe,
|
|
|
|
it,
|
|
|
|
iit,
|
|
|
|
xit,
|
|
|
|
expect,
|
|
|
|
beforeEach,
|
|
|
|
afterEach,
|
|
|
|
AsyncTestCompleter,
|
|
|
|
inject
|
2015-10-13 03:29:13 -04:00
|
|
|
} from 'angular2/testing_internal';
|
2015-11-05 17:07:57 -05:00
|
|
|
import {IS_DART} from 'angular2/src/core/facade/lang';
|
2015-08-28 14:45:39 -04:00
|
|
|
|
|
|
|
import {evalModule} from './eval_module';
|
|
|
|
|
|
|
|
// This export is used by this test code
|
|
|
|
// when evaling the test module!
|
|
|
|
export var TEST_VALUE = 23;
|
|
|
|
|
2015-11-05 17:07:57 -05:00
|
|
|
const THIS_MODULE_URL = `package:angular2/test/compiler/eval_module_spec${IS_DART?'.dart':'.js'}`;
|
2015-09-14 18:59:09 -04:00
|
|
|
|
2015-08-28 14:45:39 -04:00
|
|
|
export function main() {
|
|
|
|
describe('evalModule', () => {
|
2015-09-02 18:07:31 -04:00
|
|
|
it('should call the "run" function and allow to use imports',
|
|
|
|
inject([AsyncTestCompleter], (async) => {
|
2015-08-28 14:45:39 -04:00
|
|
|
var moduleSource = IS_DART ? testDartModule : testJsModule;
|
2015-10-01 13:07:49 -04:00
|
|
|
evalModule(moduleSource, [[THIS_MODULE_URL, 'tst']], [1])
|
2015-09-02 18:07:31 -04:00
|
|
|
.then((value) => {
|
|
|
|
expect(value).toEqual([1, 23]);
|
|
|
|
async.done();
|
|
|
|
});
|
2015-08-28 14:45:39 -04:00
|
|
|
}));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
var testDartModule = `
|
2015-09-14 18:59:09 -04:00
|
|
|
run(data) {
|
|
|
|
data.add(tst.TEST_VALUE);
|
2015-08-28 14:45:39 -04:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
var testJsModule = `
|
|
|
|
exports.run = function(data) {
|
2015-09-14 18:59:09 -04:00
|
|
|
data.push(tst.TEST_VALUE);
|
2015-08-28 14:45:39 -04:00
|
|
|
return data;
|
|
|
|
}
|
2015-10-02 10:57:29 -04:00
|
|
|
`;
|