Skip to content

Commit

Permalink
fix(core): property check Content Documents extensions
Browse files Browse the repository at this point in the history
Fixes #157
  • Loading branch information
rdeltour committed Jan 19, 2018
1 parent 28cef7f commit 8641c36
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"packages/*"
],
"devDependencies": {
"@daisy/jest-puppeteer": "^0.9.0",
"@daisy/jest-env-puppeteer": "^0.9.0",
"@daisy/jest-puppeteer": "^0.9.0",
"babel-core": "^6.0.0",
"babel-jest": "^21.2.0",
"babel-preset-env": "^1.6.0",
Expand All @@ -24,6 +24,7 @@
"rimraf": "^2.6.1",
"snyk": "^1.56.0",
"standard-version": "^4.2.0",
"strip-ansi": "^4.0.0",
"uglify-js": "^3.0.8",
"watch": "^1.0.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/ace-core/src/checker/checker-chromium.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function checkSingle(spineItem, epub, browser) {

// File extensions other than 'xhtml' or 'html' are not propertly loaded
// by puppeteer, so we copy the file to a new `.xhtml` temp file.
if (ext !== 'xhtml' && ext !== 'html') {
if (ext !== '.xhtml' && ext !== '.html') {
winston.warn(`Copying document with extension '${ext}' to a temporary '.xhtml' file…`);
const tmpdir = tmp.dirSync({ unsafeCleanup: true }).name;
const tmpFile = path.join(tmpdir, `${path.basename(spineItem.filepath, ext)}.xhtml`)
Expand Down
24 changes: 23 additions & 1 deletion tests/__tests__/cli.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
'use strict';

const path = require('path');
const stripAnsi = require('strip-ansi');

const ace = require('../runAceCLI');
const pkg = require('../../packages/ace-core/package');

const path = require('path');

describe('Running the CLI', () => {
test('with no input should fail', () => {
Expand Down Expand Up @@ -61,6 +63,26 @@ describe('Running the CLI', () => {
expect(res).toMatchObject({ '@type': 'earl:report' });
});

describe('with a valid input', () => {
test('raises no log warnings', () => {
const { stdout, stderr, status } = ace(['base-epub-30'], {
cwd: path.resolve(__dirname, '../data'),
});
const log = stripAnsi(stdout);
expect(/^warn:/m.test(log)).toBe(false);
});
});

describe('raises a warning', () => {
test('when the EPUB Content Docs have unusual extensions', () => {
const { stdout, stderr, status } = ace(['issue-122'], {
cwd: path.resolve(__dirname, '../data'),
});
const log = stripAnsi(stdout);
expect(/^warn:\s+Copying document with extension/m.test(log)).toBe(true);
});
});

/*test('with return-2-on-validation-error set to true should exit with return code 2', () => {
// TODO this test won't work until we can specify the CLI option to enable returning 2 on violation(s)
const { stdout, stderr, status } = ace(['has-violations'], {
Expand Down

0 comments on commit 8641c36

Please sign in to comment.