From 1e92a0994b86c3f959548defe6cfdcab425627e2 Mon Sep 17 00:00:00 2001 From: Marco Araujo Date: Tue, 3 Jan 2017 21:18:42 -0200 Subject: [PATCH] Increase tests --- app/components/Offline/Offline.js | 2 +- codecov.yml | 28 +++++++++++++++++++++++++ tests/Offline.test.js | 35 +++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 codecov.yml create mode 100644 tests/Offline.test.js diff --git a/app/components/Offline/Offline.js b/app/components/Offline/Offline.js index d203145..470dc00 100644 --- a/app/components/Offline/Offline.js +++ b/app/components/Offline/Offline.js @@ -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 : ''}}); diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..f253b79 --- /dev/null +++ b/codecov.yml @@ -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 + diff --git a/tests/Offline.test.js b/tests/Offline.test.js new file mode 100644 index 0000000..8f7e347 --- /dev/null +++ b/tests/Offline.test.js @@ -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(); + + 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(); + + expect(component.state().networkStatus).toEqual({"display": "none"}); + done(); + + }); +});