Skip to content

Commit 1e92a09

Browse files
committed
Increase tests
1 parent 82209c0 commit 1e92a09

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

app/components/Offline/Offline.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Offline extends React.Component
1919
}
2020

2121
updateNetworkStatus() {
22-
if (navigator.onLine) {
22+
if (window.navigator.onLine) {
2323
this.setState({networkStatus: {display : 'none'}});
2424
} else {
2525
this.setState({networkStatus: {display : ''}});

codecov.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
codecov:
3+
notify:
4+
require_ci_to_pass: true
5+
comment:
6+
behavior: default
7+
layout: header, diff
8+
require_changes: false
9+
coverage:
10+
precision: 2
11+
range:
12+
- 90.0
13+
- 100.0
14+
round: down
15+
status:
16+
changes: false
17+
patch: true
18+
project: true
19+
parsers:
20+
gcov:
21+
branch_detection:
22+
conditional: true
23+
loop: true
24+
macro: false
25+
method: false
26+
javascript:
27+
enable_partials: false
28+

tests/Offline.test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
describe('Test Offline', () => {
3+
const React = require('react');
4+
const enzyme = require('enzyme');
5+
const shallow = enzyme.shallow;
6+
const Offline = require('components/Offline/Offline').default;
7+
8+
it('Offline should show message when without internet', (done) => {
9+
10+
window.navigator.__defineGetter__('onLine', function(){
11+
return false;
12+
});
13+
14+
let component = shallow(<Offline />);
15+
16+
expect(component.text()).toEqual('Off Line');
17+
expect(component.state().networkStatus).toEqual({"display": ""});
18+
19+
done();
20+
21+
});
22+
23+
it('Offline should display none when with internet', (done) => {
24+
25+
window.navigator.__defineGetter__('onLine', function(){
26+
return true;
27+
});
28+
29+
let component = shallow(<Offline />);
30+
31+
expect(component.state().networkStatus).toEqual({"display": "none"});
32+
done();
33+
34+
});
35+
});

0 commit comments

Comments
 (0)