/
leia.js
63 lines (58 loc) · 2.31 KB
/
leia.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
'use strict';
module.exports = class Leia {
constructor() {};
/**
* Takes an array of glob patterns and returns a unique list of all the matching files
*
* @since 0.5.0
* @param {Array} patterns An array of GLOB patterns
* @param {Array} ignore An array of GLOB patterns
* @return {Array} An array of unique absolute filepaths
* @example
* const find = require(./find');
* const files = find(['./examples/*.md']);
*/
find(patterns, ignore) {
return require('./find')(patterns, ignore);
}
/**
* Takes an array of parsed leia test metadata and generates mocha cli tests
*
* @since 0.5.0
* @param {Array} tests An array of parsed leia test metadata
* @param {Object} [options] Options to pass to the dot template engine
* @param {Boolean} [options.strip=false] Strips things
* @return {Array} An array of unique absolute filepaths
*/
generate(tests, options) {
return require('./generate')(tests, options);
}
/**
* Takes an array of absolute pathed markdown files and generates leia testing metadata
*
* @since 0.5.0
* @param {Array} files An array of absolute paths to markdown files
* @param {Object} [options] An array of options
* @param {Array} [options.cleanupHeader=['Clean']] An array of words that h2 headers can start with to be flagged as cleanup commands
* @param {Integer} [options.retry=3] Amount of times to retry each test
* @param {Array} [options.setupHeader=['Setup']] An array of words h2 headers can start with to be flagged as setup commands
* @param {String} [options.shell=autodetected] A string containing the shell to run tests with
* @param {Boolean} [options.stdin=false] A boolean to attach stdin or not
* @param {Array} [options.testHeader=['Test']] An array of words h2 headers can start with to flagged as test commands
* @return {Object} An object of parsed leia test metadate that you can use to generate mocha tests
*/
parse(files, options) {
return require('./parse')(files, options);
}
/**
* Runs tests
*
* @since 0.5.0
* @param {Array} tests An array of absolute paths to generated leia test files
* @param {Object} [options] An array of Mocha options
* @return {Object} A test loaded mocha instance
*/
run(tests, options) {
return require('./run')(tests, options);
}
};