-
Notifications
You must be signed in to change notification settings - Fork 0
/
solution.js
46 lines (40 loc) · 1.74 KB
/
solution.js
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
36
37
38
39
40
41
42
43
44
45
46
// 61: modules - import (solution)
// To do: make all tests pass, leave the assert lines unchanged!
import assert from 'assert'; // is only here for completeness, `assert` is always imported by default
import { equal } from 'assert';
import { deepEqual, notEqual } from 'assert';
import { equal as myEqual } from 'assert';
import myAssert from 'assert'; // equivalent to -> import { default as myAssert } from 'assert';
describe('use `import` to import functions that have been exported (somewhere else)', function() {
describe('the import statement', function() {
it('is only allowed on the root level', function() {
// try to comment this out, it will yell at you :)
// import assert from 'assert';
});
it('import an entire module using `import <name> from "<moduleName>"`', function() {
// this can't fail, since `assert` is imported by default
assert.equal(typeof assert, 'function');
});
});
describe('import members', function() {
it('import a single member, using `import {<memberName>} from "module"`', function() {
assert.strictEqual(equal, assert.equal);
});
describe('separate multiple members with a comma', function() {
it('`deepEqual` from the assert module', () => {
assert.strictEqual(deepEqual, assert.deepEqual);
});
it('`notEqual` from the assert module', () => {
assert.strictEqual(notEqual, assert.notEqual);
});
});
});
describe('alias imports', function() {
it('using `member as alias` as memberName', function() {
assert.strictEqual(myEqual, assert.equal);
});
it('rename the default export of a module, using `default as alias` as memberName', function() {
assert.strictEqual(myAssert, assert);
});
});
});