-
Notifications
You must be signed in to change notification settings - Fork 0
/
kata.js
36 lines (25 loc) · 968 Bytes
/
kata.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
// 36: Symbol.keyFor - retrieves a shared symbol key from the global symbol registry
// To do: make all tests pass, leave the assert lines unchanged!
describe('`Symbol.keyFor()` gets the symbol key for a given symbol', function() {
const sym = Symbol.for('foo');
it('pass the symbol to `keyFor()` and you get its key', function() {
const key = Symbol.____(sym);
assert.equal(key, 'foo');
});
it('local symbols are not in the runtime-wide registry', function() {
// hint: `Symbol()` creates a local symbol!
const localSymbol = Symbol.for('foo');
const key = Symbol.keyFor(localSymbol);
assert.equal(key, void 0);
});
it('predefined symbols are not in the runtime-wide registry either', function() {
const key = Symbol.keyFor(Symbol.iteraTor);
assert.equal(key, void 0);
});
it('for non-Symbols throws an error', function() {
function fn() {
Symbol.keyFor(sym);
}
assert.throws(fn);
});
});