Skip to content

Commit

Permalink
feat: do not put space before title if there is no root suite
Browse files Browse the repository at this point in the history
  • Loading branch information
unlok committed Jan 27, 2022
1 parent 83249ff commit f905879
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/gui/tool-runner/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ exports.getShortMD5 = (str) => {
};

exports.mkFullTitle = ({suite, state}) => {
// https://github.com/mochajs/mocha/blob/v2.4.5/lib/runnable.js#L165
return `${suite.path.join(' ')} ${state.name}`;
return suite.path.length > 0
? `${suite.path.join(' ')} ${state.name}`
: state.name;
};

// 'databaseUrls.json' may contain many databases urls but html-reporter at gui mode can work with single databases file.
Expand Down
21 changes: 21 additions & 0 deletions test/unit/lib/gui/tool-runner/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

const {mkFullTitle} = require('lib/gui/tool-runner/utils');

describe('lib/gui/tool-runner/utils', () => {
describe('mkFullTitle', () => {
it('should build title if array with path is not empty', () => {
const suite = {path: ['p1', 'p2']};
const state = {name: 'state'};

assert.equal(mkFullTitle({suite, state}), 'p1 p2 state');
});

it('should build title if array with path is empty', () => {
const suite = {path: []};
const state = {name: 'state'};

assert.equal(mkFullTitle({suite, state}), 'state');
});
});
});

0 comments on commit f905879

Please sign in to comment.