Skip to content

Commit f0623b4

Browse files
Merge pull request #23 from getmimo/thomas/dev-67-update-falcon-library
updated tests and falcon to support executable lessons
2 parents a8553de + 93fcbe7 commit f0623b4

File tree

8 files changed

+423
-23
lines changed

8 files changed

+423
-23
lines changed

dist/falcon/index.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ const deepEqual = require('deep-equal');
55
const beforeEachStack = [[]];
66
// Runs every beforeEach callback in the stack
77
const runEveryBeforeEach = () => {
8-
beforeEachStack.forEach(level => level.forEach(cb => cb()));
8+
beforeEachStack.forEach((level) => level.forEach((cb) => cb()));
99
};
10-
const beforeEach = cb => {
10+
const beforeEach = (cb) => {
1111
beforeEachStack[beforeEachStack.length - 1].push(cb);
1212
};
1313

@@ -16,13 +16,31 @@ const summary = { success: true, testResults: [] };
1616
let tempResult = { logs: '' };
1717

1818
let consoleLogCache = console.log;
19-
console.log = input => {
19+
console.log = (input) => {
2020
tempResult.logs =
2121
tempResult.logs === '' ? input + '' : tempResult.logs + '\n' + input;
2222
};
2323

24+
/**
25+
We are overloading this function. It can be used with either 2 or 3 params
26+
* using it with 2 params means the first param is the `title` and the second is the `callback`
27+
* using it with 3 params means the first param is the test `input`, the second is the `title` and the third is the `callback`
28+
*/
2429
// Declares a test unit
25-
const test = (input, title, cb) => {
30+
const test = (param1, param2, param3) => {
31+
let input;
32+
let title;
33+
let cb;
34+
// This check sets the function up for overloading the params. If the second param is a function, we ignore the third param
35+
// if the second param is not a function, we expect 3 params to be provided.
36+
if (typeof param2 == 'function') {
37+
title = param1;
38+
cb = param2;
39+
} else {
40+
input = param1;
41+
title = param2;
42+
cb = param3;
43+
}
2644
runEveryBeforeEach();
2745
tempResult = { logs: '' };
2846
tempResult.input = input;

falcon/index.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ const deepEqual = require('deep-equal');
55
const beforeEachStack = [[]];
66
// Runs every beforeEach callback in the stack
77
const runEveryBeforeEach = () => {
8-
beforeEachStack.forEach(level => level.forEach(cb => cb()));
8+
beforeEachStack.forEach((level) => level.forEach((cb) => cb()));
99
};
10-
const beforeEach = cb => {
10+
const beforeEach = (cb) => {
1111
beforeEachStack[beforeEachStack.length - 1].push(cb);
1212
};
1313

@@ -16,13 +16,31 @@ const summary = { success: true, testResults: [] };
1616
let tempResult = { logs: '' };
1717

1818
let consoleLogCache = console.log;
19-
console.log = input => {
19+
console.log = (input) => {
2020
tempResult.logs =
2121
tempResult.logs === '' ? input + '' : tempResult.logs + '\n' + input;
2222
};
2323

24+
/**
25+
We are overloading this function. It can be used with either 2 or 3 params
26+
* using it with 2 params means the first param is the `title` and the second is the `callback`
27+
* using it with 3 params means the first param is the test `input`, the second is the `title` and the third is the `callback`
28+
*/
2429
// Declares a test unit
25-
const test = (input, title, cb) => {
30+
const test = (param1, param2, param3) => {
31+
let input;
32+
let title;
33+
let cb;
34+
// This check sets the function up for overloading the params. If the second param is a function, we ignore the third param
35+
// if the second param is not a function, we expect 3 params to be provided.
36+
if (typeof param2 == 'function') {
37+
title = param1;
38+
cb = param2;
39+
} else {
40+
input = param1;
41+
title = param2;
42+
cb = param3;
43+
}
2644
runEveryBeforeEach();
2745
tempResult = { logs: '' };
2846
tempResult.input = input;

package-lock.json

Lines changed: 65 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"test": "tsc && jest",
1010
"test-watch": "tsc && jest --watch",
1111
"test-testrunner-example": "node ./testrunner-examples/test.js",
12+
"test-falcon-2": "node ./testrunner-examples/test-falcon-2.js",
1213
"build": "tsc && cp ./falcon/index.js dist/falcon/index.js",
1314
"test-verbose": "tsc && jest --verbose"
1415
},
@@ -21,6 +22,9 @@
2122
],
2223
"license": "ISC",
2324
"dependencies": {
25+
"chai": "^4.3.4",
26+
"chai-dom": "^1.10.0",
27+
"chai-things": "^0.2.0",
2428
"deep-equal": "^1.1.1",
2529
"jquery": "3.4.0"
2630
},
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head> </head>
4+
<body>
5+
<div></div>
6+
</body>
7+
</html>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
<div></div>
5+
</body>
6+
</html>

testrunner-examples/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
<body>
55
<img src="" />
66
<div id="votes"></div>
7+
<div>
8+
<h1>asd</h1>
9+
</div>
710
</body>
811
</html>

0 commit comments

Comments
 (0)