Skip to content

Commit

Permalink
Feature/context nocode (#9)
Browse files Browse the repository at this point in the history
* enable context when enableCode is false; add context icon

* update docs

* update dist files
  • Loading branch information
adamgruber authored Feb 15, 2017
1 parent 4b10db9 commit b9e6cb2
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 54 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#Changelog

###1.0.7
- Fix an issue where test context could not be viewed if `enableCode` option was `false`. [mochawesome #132](https://github.com/adamgruber/mochawesome/issues/132)
- Add an icon to indicate when a test has context

###1.0.6
- Layout and style fixes [mochawesome #118](https://github.com/adamgruber/mochawesome/issues/118)

Expand Down
2 changes: 1 addition & 1 deletion dist/assets/external/app.css

Large diffs are not rendered by default.

53 changes: 29 additions & 24 deletions dist/assets/external/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/assets/inline/app.css

Large diffs are not rendered by default.

53 changes: 29 additions & 24 deletions dist/assets/inline/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mochawesome-report-generator",
"version": "1.0.6",
"version": "1.0.7",
"description": "Generates gorgeous HTML reports from mochawesome reporter.",
"scripts": {
"lint": "eslint bin lib src/js src/components/**/*.js src/components/**/*.jsx test/**/*.js test/**/*.jsx",
Expand Down
14 changes: 13 additions & 1 deletion src/components/test/test.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
font-size: 13px;
line-height: 24px;
margin: 0;
padding: 0 60px 0 40px;
padding: 0 80px 0 40px;
@nest .with-context & {
padding-right: 106px;
}
}

.icon {
Expand Down Expand Up @@ -94,6 +97,15 @@
}
}

.context-icon {
float: left;
line-height: 24px !important;
color: var(--black38);
margin-right: 8px;
position: relative;
top: 1px;
}

.body {
display: none;
background-color: var(--grey50);
Expand Down
6 changes: 4 additions & 2 deletions src/components/test/test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Test extends React.Component {

toggleExpandedState() {
const { test, enableCode } = this.props;
if ((enableCode && test.pass) || test.fail) {
if ((enableCode && test.pass) || !!test.context || test.fail) {
this.setState({ expanded: !this.state.expanded });
}
}
Expand Down Expand Up @@ -65,7 +65,8 @@ class Test extends React.Component {
failed: fail,
pending,
skipped,
inactive: pending || skipped || (!enableCode && pass)
inactive: pending || skipped || (pass && !enableCode && !context),
'with-context': !!context
});

return (
Expand All @@ -76,6 +77,7 @@ class Test extends React.Component {
<h4 className={ cx('title') }>{ title }</h4>
</div>
<div className={ cx('info') }>
{ !!context && <Icon name='chat_bubble_outline' className={ cx('context-icon') } size={ 18 } /> }
<Duration className={ cx('duration') } timer={ duration } />
<Icon name='timer' className={ cx('duration-icon', speed) } size={ 18 } />
</div>
Expand Down
9 changes: 9 additions & 0 deletions test/spec/components/test/test.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ describe('<Test />', () => {
expect(setStateSpy.calledOnce).to.equal(false);
});

it('renders passing test with context, enableCode: false', () => {
const { wrapper, snippets, errorMsg } = getInstance({ test: passingTestWithContext, enableCode: false });
expect(snippets).to.have.lengthOf(2);
expect(errorMsg).to.have.lengthOf(0);
wrapper.simulate('click');
expect(toggleSpy.calledOnce).to.equal(true);
expect(setStateSpy.calledOnce).to.equal(true);
});

it('renders failing test', () => {
const { wrapper, snippets, errorMsg } = getInstance({ test: failingTest });
expect(snippets).to.have.lengthOf(3);
Expand Down

0 comments on commit b9e6cb2

Please sign in to comment.