-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test : functionnal login modal and unit tests
- Loading branch information
Showing
9 changed files
with
231 additions
and
13 deletions.
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
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
57 changes: 57 additions & 0 deletions
57
src/app/common/auth/component/login-form-component.spec.js
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,57 @@ | ||
import {shallow} from 'enzyme' | ||
import {expect} from 'chai' | ||
import { Field } from 'redux-form' | ||
import { LoginFormComponent } from './login-form-component' | ||
|
||
describe('LoginFormComponent', () => { | ||
describe('render', () => { | ||
const props = { | ||
handleSubmit: () => 0 | ||
} | ||
let compo = null | ||
|
||
beforeEach(() => { | ||
compo = new LoginFormComponent(props) | ||
}) | ||
|
||
it('Expect to contain 1 form with valid className and valid onSubmit', () => { | ||
const wrapper = shallow(compo.render()) | ||
const actual = wrapper.find('form').findWhere(n => { | ||
return n.prop('onSubmit') === props.handleSubmit && n.prop('className') === 'luciole-form' | ||
}) | ||
expect(actual).to.have.length(1) | ||
}) | ||
|
||
it('Expect to contain 1 Field with valid name and type', () => { | ||
const wrapper = shallow(compo.render()) | ||
const actual = wrapper.find(Field).findWhere(n => { | ||
return n.prop('name') === 'mail' && n.prop('type') === 'email' | ||
}) | ||
expect(actual).to.have.length(1) | ||
}) | ||
|
||
it('Expect to contain 1 Field with valid name and type', () => { | ||
const wrapper = shallow(compo.render()) | ||
const actual = wrapper.find(Field).findWhere(n => { | ||
return n.prop('name') === 'password' && n.prop('type') === 'password' | ||
}) | ||
expect(actual).to.have.length(1) | ||
}) | ||
|
||
it('Expect to contain 1 div with valid className', () => { | ||
const wrapper = shallow(compo.render()) | ||
const actual = wrapper.find('div').findWhere(n => { | ||
return n.prop('className') === 'buttons' | ||
}) | ||
expect(actual).to.have.length(1) | ||
}) | ||
|
||
it('Expect to contain 1 button with valid className', () => { | ||
const wrapper = shallow(compo.render()) | ||
const actual = wrapper.find('button').findWhere(n => { | ||
return n.prop('className') === 'luciole-buttons' | ||
}) | ||
expect(actual).to.have.length(1) | ||
}) | ||
}) | ||
}) |
72 changes: 72 additions & 0 deletions
72
src/app/common/auth/component/login-modal-component.spec.js
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,72 @@ | ||
import {shallow} from 'enzyme' | ||
import {expect} from 'chai' | ||
import LuLoginModal from './login-modal-component' | ||
import { Modal } from 'react-bootstrap' | ||
import LoginFormComponent from './login-form-component' | ||
|
||
describe('LuLoginModal', () => { | ||
describe('render', () => { | ||
const props = { | ||
show: true, | ||
handleLogin: () => 0, | ||
handleClose: () => 0, | ||
handleSignup: () => 0 | ||
} | ||
let compo | ||
|
||
beforeEach(() => { | ||
compo = new LuLoginModal(props) | ||
}) | ||
|
||
it('Expect to contain a Modal', () => { | ||
const wrapper = shallow(compo.render()) | ||
const actual = wrapper.instance() | ||
expect(actual).to.be.instanceOf(Modal) | ||
}) | ||
|
||
it('Expect to contain a Modal with show prop', () => { | ||
const wrapper = shallow(compo.render()) | ||
const actual = wrapper.instance() | ||
expect(actual.props.show).to.equals(true) | ||
}) | ||
|
||
it('Expect to contain a Modal with show prop', () => { | ||
const wrapper = shallow(compo.render()) | ||
const actual = wrapper.instance() | ||
expect(actual.props.onHide).to.equals(props.handleClose) | ||
}) | ||
|
||
it('Expect to contain a button with onClick prop', () => { | ||
const wrapper = shallow(compo.render()) | ||
const actual = wrapper.find('button').prop('onClick') | ||
const expected = props.handleSignup | ||
expect(actual).to.be.equal(expected) | ||
}) | ||
|
||
it('Expect to contain 1 Modal.Title', () => { | ||
const wrapper = shallow(compo.render()) | ||
const actual = wrapper.find(Modal.Title) | ||
expect(actual).to.have.length(1) | ||
}) | ||
|
||
it('Expect to contain 1 Modal.Body', () => { | ||
const wrapper = shallow(compo.render()) | ||
const actual = wrapper.find(Modal.Body) | ||
expect(actual).to.have.length(1) | ||
}) | ||
|
||
it('Expect to contain 1 Modal.Footer', () => { | ||
const wrapper = shallow(compo.render()) | ||
const actual = wrapper.find(Modal.Footer) | ||
expect(actual).to.have.length(1) | ||
}) | ||
|
||
it('Expect to contain 1 LoginFormComponent with valid prop', () => { | ||
const wrapper = shallow(compo.render()) | ||
const actual = wrapper.find(LoginFormComponent).findWhere(n => { | ||
return n.prop('onSubmit') === props.handleLogin | ||
}) | ||
expect(actual).to.have.length(1) | ||
}) | ||
}) | ||
}) |
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
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
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
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
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