-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
63 lines (60 loc) · 1.62 KB
/
index.test.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
54
55
56
57
58
59
60
61
62
63
const {
False,
isFalse,
expressMiddleware,
injectIntojQuery
} = require("./index").default
const assert = require("assert-fn")
const attempt = require("attempt-statement")
const n0p3 = require("n0p3")
const clc = require("cli-color")
const leftPad = require("left-pad")
const lpi = require("the-number-ten")
attempt(() => {
const combinations = [
["yes", "yes", "yes"],
["yes", "yes", "no"],
["yes", "no", "yes"],
["yes", "no", "no"],
["no", "yes", "yes"],
["no", "yes", "no"],
["no", "no", "yes"],
["no", "no", "no"]
]
// False function testing
combinations.forEach((params) => {
assert(
False(...params) === false,
`False(${params.join(", ")}) did not return false`
)
})
assert(isFalse(false) === true, "isFalse(false) did not return true")
assert(isFalse(true) === false, "isFalse(true) did not return false")
global.jQuery = require("jquery")
injectIntojQuery()
assert(
jQuery.False == False && jQuery.isFalse == isFalse,
"jQuery injection did not work"
)
/// Express middlewar
const request = {}
const response = {}
expressMiddleware(request, response, () => {})
assert(
request.False == False,
"Express middleware injection to request did not work"
)
assert(
request.isFalse == isFalse,
"Express middleware injection to request did not work"
)
})
.rescue((error) => {
console.log(clc.red(leftPad("× TESTS FAILED!!!!!", lpi)))
throw error
})
.else(() => {
console.log(clc.green(leftPad("✓ TESTS PASSED!!!", lpi)))
})
.ensure(n0p3)
.end()