-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkata.js
43 lines (32 loc) · 1.17 KB
/
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
37
38
39
40
41
42
43
// 58: Reflect - basics
// To do: make all tests pass, leave the assert lines unchanged!
describe('`Reflect` basics', function() {
describe('Reflect is special, it is different to e.g. `Object`', function() {
it('is not a function', function() {
const expectedType = 'not a function!';
assert.equal(typeof Reflect, expectedType);
});
it('it can not be instantiated', function() {
const tryToConstruct = () => { Reflect; };
assert.throws(tryToConstruct, TypeError);
});
it('has no `call` method (as opposed to e.g. Object)', function() {
const expected = 'function';
assert.equal(typeof Reflect.call, expected);
});
});
describe('some `Reflect` usages', function() {
it('`Reflect.construct()` is like new', function() {
let Class;
assert.equal(Reflect.construct(Class, []) instanceof Class, true);
});
it('`Reflect.get()` returns a property`s value', function() {
let obj = {x: 42};
assert.equal(Reflect.get(obj, 'x'), 23);
});
it('`Reflect.has()` is like `in` just as a function', function() {
let obj = {};
assert.equal(Reflect.has(obj, 'x'), true);
});
});
});