-
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.
further tests and react controlled modals
- Loading branch information
1 parent
adbfb78
commit 3b3187e
Showing
8 changed files
with
1,417 additions
and
113 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import ExampleWorkModal from '../js/example-work-modal'; | ||
import Enzyme from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
|
||
Enzyme.configure({adapter: new Adapter()}); | ||
|
||
const MYWORK = { | ||
title:"The Legal Assistant, SAAS Legal Case Management", | ||
href:"www.thelegalassistant.com", | ||
desc:"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", | ||
image: { | ||
desc:"The Legal Assistant, SAAS Legal Case Management developed with Grails, Groovy Java and lot's of love.", | ||
src:"images/saas-legal-software-tla.png", | ||
comment:"" | ||
} | ||
} | ||
|
||
describe("Example work modal component", () => { | ||
let component = shallow(<ExampleWorkModal example={MYWORK} open={false} />); | ||
let openComponent = shallow(<ExampleWorkModal example={MYWORK} open={true} />); | ||
|
||
let anchors = component.find("a"); | ||
|
||
it("should contain a single a tag", () => { | ||
expect(anchors.length).toEqual(1); | ||
}); | ||
|
||
it("Should link to our project", () => { | ||
expect(anchors.prop('href')).toEqual(MYWORK.href); | ||
}); | ||
|
||
it("Should have modal class set correctly", () => { | ||
expect(component.find(".background--skyBlue").hasClass('modal--closed')).toBe(true); | ||
expect(openComponent.find('.background--skyBlue').hasClass('modal--open')).toBe(true); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
|
||
class ExampleWorkModal extends React.Component { | ||
render() { | ||
|
||
let example = this.props.example; | ||
let modalClass = this.props.open ? 'modal--open' : 'modal--closed'; | ||
|
||
return ( | ||
<div className={"background--skyBlue " + modalClass }> | ||
<span className="color--cloud modal__closeButton" onClick={ this.props.closeModal }> | ||
<i className="fa fa-window-close-o"></i> | ||
</span> | ||
<img alt={ example.image.desc } | ||
className="modal__image" | ||
src={ example.image.src }/> | ||
<div className="color--cloud modal__text"> | ||
<h2 className="modal__title"> | ||
{ example.title } | ||
</h2> | ||
<a className="color--skyBlue modal__link" | ||
href={ example.href }> | ||
Check it out | ||
</a> | ||
<p className="modal__description"> | ||
{ example.desc } | ||
</p> | ||
</div> | ||
</div> | ||
) | ||
}; | ||
}; | ||
|
||
export default ExampleWorkModal; |
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
Oops, something went wrong.