-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tests): add minimal integration tests
- Loading branch information
Showing
5 changed files
with
665 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
module.exports = { | ||
"extends": "airbnb-base", | ||
"env": { | ||
"jest": true | ||
}, | ||
"rules": { | ||
"no-console": 0 | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const tmp = require('tmp'); | ||
|
||
const ace = require('../../src/core/ace.js'); | ||
|
||
let outdir; | ||
let tmpdir; | ||
|
||
tmp.setGracefulCleanup(); | ||
|
||
beforeEach(() => { | ||
outdir = tmp.dirSync({ prefix: 'ace_out_', unsafeCleanup: true }); | ||
tmpdir = tmp.dirSync({ prefix: 'ace_tmp_', unsafeCleanup: true }); | ||
}); | ||
|
||
afterEach(() => { | ||
outdir.removeCallback(); | ||
tmpdir.removeCallback(); | ||
}); | ||
|
||
function runAce(epub) { | ||
return ace(epub, { | ||
cwd: process.cwd(), | ||
outdir: outdir.name, | ||
tmpdir: tmpdir.name, | ||
verbose: true, | ||
silent: true, | ||
}); | ||
} | ||
|
||
test('unexisting EPUB fails with an error', () => { | ||
expect.assertions(1); | ||
return expect(runAce('noepub')) | ||
.rejects.toMatch(''); | ||
}); | ||
|
||
test('report dir is correctly created', async () => { | ||
expect.assertions(1); | ||
return runAce(path.join(__dirname, '../data/base-epub-30.epub')).then(() => { | ||
expect(fs.existsSync(path.join(outdir.name, 'report.html'))).toBeTruthy(); | ||
}); | ||
}); |
Binary file not shown.
Oops, something went wrong.