-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkata.js
53 lines (41 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
44
45
46
47
48
49
50
51
52
53
// 22: class - creation
// To do: make all tests pass, leave the assert lines unchanged!
describe('class creation', () => {
it('is as simple as `class XXX {}`', function() {
let TestClass;
const instance = new TestClass();
assert.equal(typeof instance, 'object');
});
it('class is block scoped', () => {
class Inside {}
{class Inside {}}
assert.equal(typeof Inside, 'undefined');
});
it('special method is `constructor`', function() {
class User {
constructor(id) {}
}
const user = new User(42);
assert.equal(user.id, 42);
});
it('defining a method is simple', function() {
class User {
}
const notATester = new User();
assert.equal(notATester.writesTests(), false);
});
it('multiple methods need no commas (opposed to object notation)', function() {
class User {
wroteATest() { this.everWroteATest = true; }
isLazy() { }
}
const tester = new User();
assert.equal(tester.isLazy(), true);
tester.wroteATest();
assert.equal(tester.isLazy(), false);
});
it('anonymous class', () => {
const classType = typeof {};
assert.equal(classType, 'function');
});
});