-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTests.js
26 lines (24 loc) · 797 Bytes
/
Tests.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
'use strict'
const Dir = require('./elhin/Dir')
const Test_result = require('./Test_result')
const shell = require('./elhin/Shell')()
const Tests = (project_dir, object = {}) => {
object.collect_files = () => {
const test_dir = project_dir.get_contained_dir('tests')
return test_dir.get_files_with_extension_recursive('js')
}
object.run = (test_file_array) => {
const test_result_array = []
for(let test_file of test_file_array) {
const test_result = Test_result()
test_result.test_file = test_file
let shell_result = shell.run('node', [test_file.path])
test_result.shell_result = shell_result
test_result.assertion_results.push(shell_result.status === 0)
test_result_array.push(test_result)
}
return test_result_array
}
return object
}
module.exports = Tests