push
github
520 of 593 branches covered (87.69%)
Branch coverage included in aggregate %.
98 of 104 new or added lines in 8 files covered. (94.23%)
109 existing lines in 5 files now uncovered.2746 of 3028 relevant lines covered (90.69%)
412.21 hits per line
|
import json from './JSONDriver.js' |
|
|
import {parse} from './grammar.js' |
4✔ |
|
import pdf from './PDFDriver.js' |
4✔ |
|
import svg from './SVGDriver.js' |
4✔ |
5 |
|
4✔ |
6 |
const outputs = { |
4✔ |
|
js: json,
|
4✔ |
|
json, |
4✔ |
|
pdf, |
4✔ |
|
svg, |
4✔ |
11 |
} |
4✔ |
12 |
|
4✔ |
|
export function supported(output_type) { |
|
14 |
return Object.prototype.hasOwnProperty.call(outputs, output_type)
|
12✔ |
15 |
} |
12✔ |
16 |
|
4✔ |
|
export function draw(input, argv, outstream) { |
|
|
return new Promise((resolve, reject) => { |
|
|
if (typeof argv === 'string') { |
|
|
argv = {o: argv}
|
4✔ |
|
} |
4✔ |
|
const output_type = argv.o |
12✔ |
|
if (!supported(output_type)) {
|
|
NEW
|
reject(new Error(`Invalid output type: "${output_type}"`)) |
× |
NEW
|
return
|
× |
NEW
|
} |
× |
27 |
const Driver = outputs[output_type] |
12✔ |
|
const parsed = parse(input) |
12✔ |
|
const driver = new Driver(parsed, argv)
|
12✔ |
|
driver.draw(outstream, er => { |
|
|
if (er) {
|
|
NEW
|
reject(er) |
× |
|
} else {
|
12✔ |
|
resolve(outstream) |
12✔ |
|
} |
12✔ |
|
}) |
12✔ |
|
}) |
12✔ |
38 |
} |
12✔ |