Skip to content

Commit

Permalink
Increase tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoaraujojunior committed Jan 3, 2017
1 parent 82209c0 commit 1e92a09
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/components/Offline/Offline.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Offline extends React.Component
}

updateNetworkStatus() {
if (navigator.onLine) {
if (window.navigator.onLine) {
this.setState({networkStatus: {display : 'none'}});
} else {
this.setState({networkStatus: {display : ''}});
Expand Down
28 changes: 28 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

codecov:
notify:
require_ci_to_pass: true
comment:
behavior: default
layout: header, diff
require_changes: false
coverage:
precision: 2
range:
- 90.0
- 100.0
round: down
status:
changes: false
patch: true
project: true
parsers:
gcov:
branch_detection:
conditional: true
loop: true
macro: false
method: false
javascript:
enable_partials: false

35 changes: 35 additions & 0 deletions tests/Offline.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

describe('Test Offline', () => {
const React = require('react');
const enzyme = require('enzyme');
const shallow = enzyme.shallow;
const Offline = require('components/Offline/Offline').default;

it('Offline should show message when without internet', (done) => {

window.navigator.__defineGetter__('onLine', function(){
return false;
});

let component = shallow(<Offline />);

expect(component.text()).toEqual('Off Line');
expect(component.state().networkStatus).toEqual({"display": ""});

done();

});

it('Offline should display none when with internet', (done) => {

window.navigator.__defineGetter__('onLine', function(){
return true;
});

let component = shallow(<Offline />);

expect(component.state().networkStatus).toEqual({"display": "none"});
done();

});
});

0 comments on commit 1e92a09

Please sign in to comment.