Files
angular-docs-cn/modules/angular2/test/compiler/eval_module_spec.ts
T

51 lines
1.1 KiB
TypeScript
Raw Normal View History

2015-08-28 11:45:39 -07:00
import {
ddescribe,
describe,
xdescribe,
it,
iit,
xit,
expect,
beforeEach,
afterEach,
AsyncTestCompleter,
inject
2015-10-13 00:29:13 -07:00
} from 'angular2/testing_internal';
2015-11-06 17:34:07 -08:00
import {IS_DART} from 'angular2/src/facade/lang';
2015-08-28 11:45:39 -07: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 14:07:57 -08:00
const THIS_MODULE_URL = `package:angular2/test/compiler/eval_module_spec${IS_DART?'.dart':'.js'}`;
2015-09-14 15:59:09 -07:00
2015-08-28 11:45:39 -07:00
export function main() {
describe('evalModule', () => {
2015-09-02 15:07:31 -07:00
it('should call the "run" function and allow to use imports',
inject([AsyncTestCompleter], (async) => {
2015-08-28 11:45:39 -07:00
var moduleSource = IS_DART ? testDartModule : testJsModule;
evalModule(moduleSource, [[THIS_MODULE_URL, 'tst']], [1])
2015-09-02 15:07:31 -07:00
.then((value) => {
expect(value).toEqual([1, 23]);
async.done();
});
2015-08-28 11:45:39 -07:00
}));
});
}
var testDartModule = `
2015-09-14 15:59:09 -07:00
run(data) {
data.add(tst.TEST_VALUE);
2015-08-28 11:45:39 -07:00
return data;
}
`;
var testJsModule = `
exports.run = function(data) {
2015-09-14 15:59:09 -07:00
data.push(tst.TEST_VALUE);
2015-08-28 11:45:39 -07:00
return data;
}
`;