Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specs #36

Merged
merged 9 commits into from
Feb 22, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/js/_admin/components/applications/application_row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class ApplicationRow extends React.Component {
application_instances_count : React.PropTypes.number,
}).isRequired,
saveApplication: React.PropTypes.func.isRequired,
}
};

static getStyles() {
return {
Expand All @@ -34,7 +34,7 @@ export default class ApplicationRow extends React.Component {
const styles = ApplicationRow.getStyles();
return (
<tr>
<td>
<td className="test-link">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't change the code for tests

<Link to={`/applications/${this.props.application.id}/application_instances`}>{this.props.application.name}</Link>
</td>
<td><span>{this.props.application.application_instances_count}</span></td>
Expand Down
49 changes: 49 additions & 0 deletions client/js/_admin/components/applications/application_row.spec.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import { Provider } from 'react-redux';
import Helper from '../../../../specs_support/helper';
import ApplicationRow from './application_row';


describe('applications application row', () => {
let result;
let props;

beforeEach(() => {

props = {
application: {
id : 314159,
name : "SPECNAME",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings must use singlequote quotes

application_instances_count : 123
},
saveApplication: () => {}
};

result = TestUtils.renderIntoDocument(
<Provider store={Helper.makeStore()}>
<table><tbody>
<ApplicationRow {...props} />
</tbody></table>
</Provider>
);

});

it('button is clicked', () => {
const button = TestUtils.findRenderedDOMComponentWithClass(result, 'i-settings');
TestUtils.Simulate.click(button);
expect(button);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write a test for the button.

});

it('renders application instances count', () => {
const span = TestUtils.findRenderedDOMComponentWithTag(result, 'span');
expect(span.textContent).toContain('123');
});

it('renders application link', () => {
const link = TestUtils.findRenderedDOMComponentWithClass(result, 'test-link');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try not to modify the code with test specific changes.

expect(link.innerText).toContain('SPECNAME');
});

});
47 changes: 47 additions & 0 deletions client/js/_admin/components/applications/form.spec.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import Stub from '../../../../specs_support/stub';
import Form from './form';

describe('applications form', () => {

let result;
let props;
let action;

beforeEach(() => {
action = false;
props = {
onChange: () => {},
closeModal: () => { action = true; },
save: () => { action = true; },
description: "SPEC_DESCRIPTION"
};

result = TestUtils.renderIntoDocument(
<Stub>
<Form {...props} />
</Stub>
);
});

it('renders a form', () => {
let button = TestUtils.findRenderedDOMComponentWithClass(result, 'c-btn c-btn--yellow');
TestUtils.Simulate.click(button);
expect(action).toBeTruthy();
});

it('close modal', () => {
let button = TestUtils.findRenderedDOMComponentWithClass(result, 'c-btn c-btn--gray--large u-m-right');
TestUtils.Simulate.click(button);
expect(action).toBeTruthy();
});

it('renders description', () => {
let element = TestUtils.findRenderedDOMComponentWithClass(result, 'o-grid o-grid__modal-top');
expect(element).toBeDefined();
let childDivs = element.childNodes;
let inputTag = childDivs[0].firstChild.childNodes[1];
expect(inputTag.value).toContain('SPEC_DESCRIPTION');
})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon semi

});
40 changes: 40 additions & 0 deletions client/js/_admin/components/applications/index.spec.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import { Provider } from 'react-redux';
import Helper from '../../../../specs_support/helper';
import { Index } from './index';

describe('applications index', () => {

let result;
let props;

beforeEach(() => {
props = {
saveApplication: () => {},
applications: {
Spiderman: {
Power1: "Wall Crawling",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings must use singlequote quotes

Power2: "Spidey Sense"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings must use singlequote quotes

}
}
};

result = TestUtils.renderIntoDocument(
<Provider store={Helper.makeStore()}>
<Index {...props} />
</Provider>
);
});

fit('render the application rows', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'fit' is not defined no-undef

let element = TestUtils.findRenderedDOMComponentWithClass(result, 'o-contain o-contain--full');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'element' is never reassigned. Use 'const' instead prefer-const

expect(element).toBeDefined();
});

fit('render application', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'fit' is not defined no-undef

let element = TestUtils.findRenderedDOMComponentWithTag(result, 'tbody');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'element' is never reassigned. Use 'const' instead prefer-const

expect(element.childNodes.length).toBeGreaterThan(0);
});

});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline required at end of file but not found eol-last

44 changes: 44 additions & 0 deletions client/js/_admin/components/applications/modal.spec.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import { Provider } from 'react-redux';
import Helper from '../../../../specs_support/helper';
import Modal from './modal';


describe('applications modal', () => {
let result;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected indentation of 2 spaces but found 4 indent

let props;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected indentation of 2 spaces but found 4 indent

let isShown;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected indentation of 2 spaces but found 4 indent

beforeEach(() => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected indentation of 2 spaces but found 4 indent

isShown = true;
props = {
application: {
name: "SPEC_NAME",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings must use singlequote quotes

description: "SPEC_STRING"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings must use singlequote quotes

},
isOpen: true,
closeModal: () => { isShown = false; },
save: () => {}
};

result = TestUtils.renderIntoDocument(
<Provider store={Helper.makeStore()} >
<Modal {...props} />
</Provider>
);
});

it('modal is shown', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected indentation of 2 spaces but found 4 indent

let modal = TestUtils.findRenderedComponentWithType(result, Modal);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'modal' is never reassigned. Use 'const' instead prefer-const

// debugger;
expect(modal).toBeDefined();
expect(modal.props.isOpen).toBeTruthy();
});

it('modal is hidden', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected indentation of 2 spaces but found 4 indent

let modal = TestUtils.findRenderedComponentWithType(result, Modal);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'modal' is never reassigned. Use 'const' instead prefer-const

expect(modal).toBeDefined();
modal.props.closeModal();
expect(isShown).toBeFalsy();
});
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline required at end of file but not found eol-last