Skip to content

Commit

Permalink
enable showHooks option (#168)
Browse files Browse the repository at this point in the history
* enable showHooks option

* update options tests
  • Loading branch information
adamgruber authored Jun 29, 2017
1 parent 4680aef commit d9a67e8
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 39 deletions.
23 changes: 12 additions & 11 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ const baseConfig = Object.assign(marge.getBaseConfig(), {
});

const boolOpts = [
'inlineAssets',
'autoOpen',
'dev',
'enableCharts',
'enableCode',
'inlineAssets',
'overwrite',
'quiet',
'useInlineDiffs',
'dev'
'useInlineDiffs'
];

function _getOption(optToGet, options, isBool) {
Expand Down Expand Up @@ -47,19 +47,20 @@ module.exports = function (opts) {
}

[
'reportFilename',
'reportDir',
'reportTitle',
'reportPageTitle',
'inlineAssets',
'autoOpen',
'dev',
'enableCharts',
'enableCode',
'timestamp',
'inlineAssets',
'inlineDiffs',
'overwrite',
'quiet',
'inlineDiffs',
'dev'
'reportDir',
'reportFilename',
'reportPageTitle',
'reportTitle',
'showHooks',
'timestamp'
].forEach(optName => {
options[optName] = _getOption(optName, reporterOpts, boolOpts.indexOf(optName) >= 0);
});
Expand Down
70 changes: 42 additions & 28 deletions test/reporter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,27 @@ const logStub = sinon.stub();

utils.log = logStub;

const baseConfig = {
reportDir: 'mochawesome-report',
reportTitle: process.cwd().split(path.sep).pop(),
reportPageTitle: 'Mochawesome Report',
inline: false,
inlineAssets: false,
charts: true,
enableCharts: true,
code: true,
enableCode: true,
autoOpen: false,
overwrite: true,
timestamp: false,
ts: false,
dev: false,
showHooks: 'failed'
};

const config = proxyquire('../src/config', {
'mochawesome-report-generator': {
getBaseConfig: () => ({
reportDir: 'mochawesome-report',
reportTitle: process.cwd().split(path.sep).pop(),
reportPageTitle: 'Mochawesome Report',
inline: false,
inlineAssets: false,
charts: true,
enableCharts: true,
code: true,
enableCode: true,
autoOpen: false,
overwrite: true,
timestamp: false,
ts: false,
dev: false
})
getBaseConfig: () => baseConfig
}
});

Expand Down Expand Up @@ -196,9 +199,12 @@ describe('Mochawesome Reporter', () => {
subSuite.addTest(test);

runner.run(failureCount => {
mochaReporter.config.reportDir.should.equal('testReportDir/subdir');
mochaReporter.config.inlineAssets.should.equal(true);
mochaReporter.config.autoOpen.should.equal(false);
const expectedConfig = Object.assign({}, baseConfig, {
reportDir: 'testReportDir/subdir',
inlineAssets: true,
autoOpen: false
});
mochaReporter.config.should.deepEqual(expectedConfig);
done();
});
});
Expand All @@ -215,7 +221,8 @@ describe('Mochawesome Reporter', () => {
inlineAssets: 'true',
enableCharts: 'true',
enableTestCode: false,
autoOpen: true
autoOpen: true,
showHooks: 'never'
}
});

Expand All @@ -224,13 +231,17 @@ describe('Mochawesome Reporter', () => {


runner.run(failureCount => {
mochaReporter.config.reportDir.should.equal('testReportDir');
mochaReporter.config.reportFilename.should.equal('testReportFilename');
mochaReporter.config.reportTitle.should.equal('testReportTitle');
mochaReporter.config.inlineAssets.should.equal(true);
mochaReporter.config.enableCharts.should.equal(true);
mochaReporter.config.enableCode.should.equal(false);
mochaReporter.config.autoOpen.should.equal(true);
const expectedConfig = Object.assign({}, baseConfig, {
reportDir: 'testReportDir',
reportFilename: 'testReportFilename',
reportTitle: 'testReportTitle',
inlineAssets: true,
enableCharts: true,
enableCode: false,
autoOpen: true,
showHooks: 'never'
});
mochaReporter.config.should.deepEqual(expectedConfig);
done();
});
});
Expand All @@ -242,7 +253,10 @@ describe('Mochawesome Reporter', () => {
subSuite.addTest(test);

runner.run(failureCount => {
mochaReporter.config.useInlineDiffs.should.equal(true);
const expectedConfig = Object.assign({}, baseConfig, {
useInlineDiffs: true
});
mochaReporter.config.should.deepEqual(expectedConfig);
done();
});
});
Expand Down

0 comments on commit d9a67e8

Please sign in to comment.