-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Creating specs for modal and app row * specs for the application folder complete * Fixing hound violations * fixing hound issues * applying what was said in the review * fixing hound error
- Loading branch information
Showing
5 changed files
with
178 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
client/js/_admin/components/applications/application_row.spec.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { 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', | ||
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).toBeDefined(); | ||
}); | ||
|
||
it('renders application instances count', () => { | ||
const span = TestUtils.findRenderedDOMComponentWithTag(result, 'span'); | ||
expect(span.textContent).toContain('123'); | ||
}); | ||
|
||
it('renders application link', () => { | ||
const linkTag = TestUtils.findRenderedDOMComponentWithTag(result, 'a'); | ||
expect(linkTag.innerText).toContain('SPECNAME'); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Stub from '../../../../specs_support/stub'; | ||
import Form from './form'; | ||
|
||
describe('applications form', () => { | ||
|
||
let result; | ||
let props; | ||
let didSave; | ||
let didClose; | ||
|
||
beforeEach(() => { | ||
didClose = false; | ||
didSave = false; | ||
props = { | ||
onChange : () => {}, | ||
closeModal : () => { didClose = true; }, | ||
save : () => { didSave = true; }, | ||
description : 'SPEC_DESCRIPTION' | ||
}; | ||
|
||
result = TestUtils.renderIntoDocument( | ||
<Stub> | ||
<Form {...props} /> | ||
</Stub> | ||
); | ||
}); | ||
|
||
it('did save', () => { | ||
const button = TestUtils.findRenderedDOMComponentWithClass(result, 'c-btn c-btn--yellow'); | ||
TestUtils.Simulate.click(button); | ||
expect(didSave).toBeTruthy(); | ||
}); | ||
|
||
it('close modal', () => { | ||
const button = TestUtils.findRenderedDOMComponentWithClass(result, 'c-btn c-btn--gray--large u-m-right'); | ||
TestUtils.Simulate.click(button); | ||
expect(didClose).toBeTruthy(); | ||
}); | ||
|
||
it('renders description', () => { | ||
const element = TestUtils.findRenderedDOMComponentWithClass(result, 'o-grid o-grid__modal-top'); | ||
expect(element).toBeDefined(); | ||
const childDivs = element.childNodes; | ||
const inputTag = childDivs[0].firstChild.childNodes[1]; | ||
expect(inputTag.value).toContain('SPEC_DESCRIPTION'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
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', | ||
Power2: 'Spidey Sense' | ||
} | ||
} | ||
}; | ||
|
||
result = TestUtils.renderIntoDocument( | ||
<Provider store={Helper.makeStore()}> | ||
<Index {...props} /> | ||
</Provider> | ||
); | ||
}); | ||
|
||
it('render the application rows', () => { | ||
const element = TestUtils.findRenderedDOMComponentWithClass(result, 'o-contain o-contain--full'); | ||
expect(element).toBeDefined(); | ||
}); | ||
|
||
it('render application', () => { | ||
const element = TestUtils.findRenderedDOMComponentWithTag(result, 'tbody'); | ||
expect(element.childNodes.length).toBeGreaterThan(0); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
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; | ||
let props; | ||
let isShown; | ||
beforeEach(() => { | ||
isShown = true; | ||
props = { | ||
application: { | ||
name : 'SPEC_NAME', | ||
description : 'SPEC_STRING' | ||
}, | ||
isOpen: true, | ||
closeModal: () => { isShown = false; }, | ||
save: () => {} | ||
}; | ||
|
||
result = TestUtils.renderIntoDocument( | ||
<Provider store={Helper.makeStore()} > | ||
<Modal {...props} /> | ||
</Provider> | ||
); | ||
}); | ||
|
||
it('modal is shown', () => { | ||
const modal = TestUtils.findRenderedComponentWithType(result, Modal); | ||
expect(modal).toBeDefined(); | ||
expect(modal.props.isOpen).toBeTruthy(); | ||
}); | ||
|
||
it('modal is hidden', () => { | ||
const modal = TestUtils.findRenderedComponentWithType(result, Modal); | ||
expect(modal).toBeDefined(); | ||
modal.props.closeModal(); | ||
expect(isShown).toBeFalsy(); | ||
}); | ||
}); |