From d06b96b011e1127d6f4058fef030654e608a94e9 Mon Sep 17 00:00:00 2001 From: rorticus Date: Fri, 8 Sep 2017 14:46:17 -0400 Subject: [PATCH] Browser unit tests by using custom intern loader --- src/tslib.ts | 45 --------------------------------------------- tests/intern.ts | 15 ++------------- tests/loader.ts | 23 ++++++++++++++++------- 3 files changed, 18 insertions(+), 65 deletions(-) delete mode 100644 src/tslib.ts diff --git a/src/tslib.ts b/src/tslib.ts deleted file mode 100644 index 57dd430..0000000 --- a/src/tslib.ts +++ /dev/null @@ -1,45 +0,0 @@ -import global from './global'; - -/** - * Provide any overrides and then load the TypeScript helpers. - */ -global.__values = function (o: any) { - let m = typeof Symbol === 'function' && o[ Symbol.iterator ], i = 0; - if (m) { - return m.call(o); - } - - if (typeof o === 'string') { - const l = o.length; - - return { - next: function () { - if (i >= l) { - return { done: true }; - } - - let char = o[ i++ ]; - if (i < l) { - let code = char.charCodeAt(0); - if ((code >= 0xD800) && (code <= 0xDBFF)) { - char += o[ i++ ]; - } - } - - return { value: char, done: false }; - } - }; - } - - return { - next: function () { - if (o && i >= o.length) { - o = void 0; - } - return { value: o && o[ i++ ], done: !o }; - } - }; -}; - -// load typescript helpers -import 'tslib'; diff --git a/tests/intern.ts b/tests/intern.ts index da3a042..9fb097f 100644 --- a/tests/intern.ts +++ b/tests/intern.ts @@ -15,22 +15,11 @@ export const capabilities = { export const maxConcurrency = 5; export const browser = { - require: [ - './node_modules/@dojo/loader/loader.js', - './_build/src/util/amd.js', - './_build/tests/loader.js', - './_build/src/main.js' - ] -}; - -export const node = { - require: [ - './_build/src/main.js' - ] + loader: './_build/tests/loader.js' }; // Non-functional test suite(s) to run in each browser -export const suites = ['_build/tests/unit/all.js']; +export const suites = ['_build/src/main.js', '_build/tests/unit/all.js']; // Functional test suite(s) to run in each browser once non-functional tests are completed export const functionalSuites = '_build/tests/functional/all'; diff --git a/tests/loader.ts b/tests/loader.ts index 2e5ce28..ed4bc40 100644 --- a/tests/loader.ts +++ b/tests/loader.ts @@ -1,7 +1,16 @@ -( require).config(shimAmdDependencies({ - packages: [ - { name: 'src', location: '_build/src' }, - { name: 'tests', location: '_build/tests' }, - { name: 'dojo', location: 'node_modules/intern/node_modules/dojo' } - ] -})); +intern.registerLoader((options) => { + return intern.loadScript('node_modules/@dojo/loader/loader.js') + .then(() => intern.loadScript('./_build/src/util/amd.js')) + .then(() => { + ( require).config(shimAmdDependencies({ + baseUrl: options.baseUrl || intern.config.basePath, + packages: [] + })); + + return (modules: string[]) => { + return new Promise((resolve, reject) => { + ( require)(modules, () => resolve()); + }); + }; + }); +});