forked from metarhia/impress
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbus.js
More file actions
35 lines (30 loc) · 1.16 KB
/
Copy pathbus.js
File metadata and controls
35 lines (30 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
const { test } = require('node:test');
const assert = require('node:assert');
const path = require('node:path');
const { Code } = require('../lib/code.js');
const root = process.cwd();
const application = {
path: path.join(root, 'test'),
console,
starts: [],
watcher: { watch() {} },
absolute(relative) {
return path.join(this.path, relative);
},
};
test('lib/bus - should load bus correctly', async () => {
const bus = new Code('bus', application);
assert.strictEqual(bus.name, 'bus');
assert.strictEqual(bus.path, path.join(root, 'test/bus'));
assert.strictEqual(typeof bus.application, 'object');
assert.deepStrictEqual(bus.tree, {});
await bus.load();
assert.deepStrictEqual(Object.keys(bus.tree), ['fakerapi', 'math', 'worldTime']);
assert.strictEqual(bus.tree.math.parent, bus.tree);
assert.strictEqual(typeof bus.tree.math, 'object');
assert.strictEqual(typeof bus.tree.math.eval, 'function');
assert.strictEqual(bus.tree.math.eval.constructor.name, 'AsyncFunction');
assert.strictEqual(typeof bus.tree.math['.service'], 'function');
assert.strictEqual(bus.tree.math['.service'].url, 'https://api.mathjs.org');
});