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