aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/__tests__
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2017-04-30 15:23:20 +0200
committerGitHub <noreply@github.com>2017-04-30 15:23:20 +0200
commitfccc9bc45ef55e3e7f14ee4a51f376c53b418991 (patch)
treea29c33256f8361d5e332ad874afede02e8b0b061 /web/src/js/__tests__
parent29ce5a83d2b4cec067731c2f2f77e1cda134c866 (diff)
parent97a00728a85a32ca6a8e98a991f6dcf28809e73b (diff)
downloadmitmproxy-fccc9bc45ef55e3e7f14ee4a51f376c53b418991.tar.gz
mitmproxy-fccc9bc45ef55e3e7f14ee4a51f376c53b418991.tar.bz2
mitmproxy-fccc9bc45ef55e3e7f14ee4a51f376c53b418991.zip
Merge pull request #2271 from mhils/mitmweb-connection-indicator
[web] add connection indicator [WIP]
Diffstat (limited to 'web/src/js/__tests__')
-rw-r--r--web/src/js/__tests__/ducks/connectionSpec.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/web/src/js/__tests__/ducks/connectionSpec.js b/web/src/js/__tests__/ducks/connectionSpec.js
new file mode 100644
index 00000000..d087e867
--- /dev/null
+++ b/web/src/js/__tests__/ducks/connectionSpec.js
@@ -0,0 +1,41 @@
+import reduceConnection from "../../ducks/connection"
+import * as ConnectionActions from "../../ducks/connection"
+import { ConnectionState } from "../../ducks/connection"
+
+describe('connection reducer', () => {
+ it('should return initial state', () => {
+ expect(reduceConnection(undefined, {})).toEqual({
+ state: ConnectionState.INIT,
+ message: null,
+ })
+ })
+
+ it('should handle start fetch', () => {
+ expect(reduceConnection(undefined, ConnectionActions.startFetching())).toEqual({
+ state: ConnectionState.FETCHING,
+ message: undefined,
+ })
+ })
+
+ it('should handle connection established', () => {
+ expect(reduceConnection(undefined, ConnectionActions.connectionEstablished())).toEqual({
+ state: ConnectionState.ESTABLISHED,
+ message: undefined,
+ })
+ })
+
+ it('should handle connection error', () => {
+ expect(reduceConnection(undefined, ConnectionActions.connectionError("no internet"))).toEqual({
+ state: ConnectionState.ERROR,
+ message: "no internet",
+ })
+ })
+
+ it('should handle offline mode', () => {
+ expect(reduceConnection(undefined, ConnectionActions.setOffline())).toEqual({
+ state: ConnectionState.OFFLINE,
+ message: undefined,
+ })
+ })
+
+})