Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
farahat80 committed Oct 14, 2019
1 parent 1b46b05 commit 419ad4d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "react-open-weather",
"bin": {},
"version": "0.5.0",
"version": "0.5.1",
"description": "React Weather component",
"main": "lib/js/ReactWeather.js",
"dependencies": {
Expand Down
34 changes: 23 additions & 11 deletions test/ReactWeather.spec.js
Expand Up @@ -8,12 +8,14 @@ import { mappedForecastData } from './fixtures/forecastdata';
describe('ReactWeather Component Shallow', () => {
let wrapper;
beforeEach(() => {
wrapper = mount(<ReactWeather
apikey='dummy-api-key'
type='city'
city='Munich'
lang='en'
/>);
wrapper = mount(
<ReactWeather
apikey="dummy-api-key"
type="city"
city="Munich"
lang="en"
/>
);
wrapper.setState({ data: mappedForecastData });
});
it('should render the component', () => {
Expand All @@ -35,19 +37,29 @@ describe('ReactWeather Component Shallow', () => {
/* global mount, spy */
describe('ReactWeather Component Render', () => {
it('should accept the props and ggenerate params object', () => {
const wrapper = mount(<ReactWeather apikey='dummy-api-key' type='city' city='Munich' lang='en'/>);
expect(wrapper.instance()._getParams()).to.deep.equal({ q: 'Munich', lang: 'en' });
const wrapper = mount(
<ReactWeather
apikey="dummy-api-key"
type="city"
city="Munich"
lang="en"
/>
);
expect(wrapper.instance()._getParams()).to.deep.equal({
q: 'Munich',
lang: 'en',
});
});
it('calls componentDidMount', () => {
spy(ReactWeather.prototype, 'componentDidMount');
mount(<ReactWeather apikey='dummy-api-key' type='city' city='Munich' />);
mount(<ReactWeather apikey="dummy-api-key" type="city" city="Munich" />);
expect(ReactWeather.prototype.componentDidMount.calledOnce).to.equal(true);
});
it('have default props', () => {
const wrapper = mount(<ReactWeather apikey='dummy-api-key' />);
const wrapper = mount(<ReactWeather apikey="dummy-api-key" />);
expect(wrapper.props().unit).to.equal('metric');
expect(wrapper.props().forecast).to.equal('today');
expect(wrapper.props().type).to.equal('auto');
expect(wrapper.props().type).to.equal('city');
expect(wrapper.props().lang).to.equal('en');
});
});

0 comments on commit 419ad4d

Please sign in to comment.