-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnitTestTest.js
More file actions
64 lines (52 loc) · 1.84 KB
/
UnitTestTest.js
File metadata and controls
64 lines (52 loc) · 1.84 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"use strict";
let UnitTest = require('./UnitTest')
// A nonsensical set of tests to demonstrate UnitTest
// These aren't truly tests of UnitTest since some are meant to fail as a demonstration
// Also it's probably weird to be testing the framework with itself
class UnitTestTest extends UnitTest {
constructor() {
// It's required that you call parent's constructor
super()
// Set some stuff up before all tests
}
helperMethod() {
// I don't do anything, but maybe one day I could
}
// In ES7 we could decorate right here where the definition is rather than below
// @UnitTest.test
colorTest() {
this.helperMethod()
this.eq("green", "green")
this.eq("blue", "blue")
this.ne("blue", "green")
this.lt("blue", "green")
}
// @UnitTest.test
arrayComparisonTest() {
this.eq([],[])
this.eq([1,4,6,4,1],[1,4,6,4,1])
}
// @UnitTest.test
badTest() {
this.eq(5, 2 + 3)
this.eq(5, 2 + 2)
this.eq("green", "blue")
this.gt("blue", "green")
}
// @UnitTest.skip("Hmm... doesn't work. Fix this with philosophy later.")
grueTest() {
this.eq("green", "blue")
this.eq("blue", "green")
}
}
// Annoying manual decoration far from function definition.
// Decorators would be much more concise and in the right place.
UnitTestTest.prototype.colorTest = UnitTest.test(UnitTestTest.prototype.colorTest)
UnitTestTest.prototype.arrayComparisonTest = UnitTest.test(UnitTestTest.prototype.arrayComparisonTest)
UnitTestTest.prototype.badTest = UnitTest.test(UnitTestTest.prototype.badTest)
UnitTestTest.prototype.grueTest = UnitTest.skip(
UnitTestTest.prototype.grueTest,
"Hmm... doesn't work. Fix this with philosophy later."
)
let unitTestTest = new UnitTestTest()
unitTestTest.run()