1 |
|
2 |
|
3 | var assert = require('assert');
|
4 |
|
5 | void require('js-string-escape');
|
6 |
|
7 |
|
8 | var submodule = require('../../../test/integration-test/test-files/submodule');
|
9 |
|
10 |
|
11 | describe('All `<script src=` Node.js integrations', function () {
|
12 | it('function as expected', function () {
|
13 |
|
14 | assert(/karma[\/\\]static[\/\\]context\.html$/.test(__filename),
|
15 | 'Expected "' + __filename + '" to end with "karma/static/context.html"');
|
16 |
|
17 | assert(/karma[\/\\]static$/.test(__dirname),
|
18 | 'Expected "' + __dirname + '" to end with "karma/static"');
|
19 | });
|
20 | });
|
21 |
|
22 | describe('module for `<script src=` based Node.js integrations', function () {
|
23 | describe('in the top level', function () {
|
24 |
|
25 | it('identify as the page itself', function () {
|
26 |
|
27 | assert(/karma[\/\\]static[\/\\]context\.html$/.test(module.filename),
|
28 | 'Expected "' + module.filename + '" to end with "karma/static/context.html"');
|
29 | assert.strictEqual(typeof module.exports, 'object');
|
30 | assert.strictEqual(module.id, '.');
|
31 | assert.strictEqual(submodule.loaded, true);
|
32 | assert.strictEqual(module.parent, null);
|
33 | });
|
34 | });
|
35 |
|
36 | describe('in a child module', function () {
|
37 |
|
38 | it('identify as a standalone module', function () {
|
39 | assert(/test[\/\\]integration-test[\/\\]test-files[\/\\]submodule\.js$/.test(submodule.filename),
|
40 | 'Expected "' + submodule.filename + '" to end with "test/integration-test/test-files/submodule.js"');
|
41 |
|
42 | assert.strictEqual(submodule.exports.hello, 'world');
|
43 | assert(/test[\/\\]integration-test[\/\\]test-files[\/\\]submodule\.js$/.test(submodule.id),
|
44 | 'Expected "' + submodule.id + '" to end with "test/integration-test/test-files/submodule.js"');
|
45 | assert.strictEqual(submodule.loaded, true);
|
46 | assert.strictEqual(submodule.parent, module);
|
47 |
|
48 |
|
49 | assert.strictEqual(submodule.hello, 'world');
|
50 |
|
51 | assert(/test[\/\\]integration-test[\/\\]test-files[\/\\]submodule\.js$/.test(submodule.filename),
|
52 | 'Expected "' + submodule.filename + '" to end with "test/integration-test/test-files/submodule.js"');
|
53 |
|
54 | assert(/test[\/\\]integration-test[\/\\]test-files$/.test(submodule.dirname),
|
55 | 'Expected "' + submodule.dirname + '" to end with "test/integration-test/test-files"');
|
56 | });
|
57 |
|
58 | it('has same window context as parent', function () {
|
59 | assert.strictEqual(submodule.before, window.before);
|
60 | });
|
61 | });
|
62 | });
|