aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/__tests__/ducks/connectionSpec.js
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2017-04-29 19:43:59 +0200
committerMaximilian Hils <git@maximilianhils.com>2017-04-29 19:43:59 +0200
commit97a00728a85a32ca6a8e98a991f6dcf28809e73b (patch)
treedd4718766f4e3e2b22d4dc76e57a24a414b5a4ac /web/src/js/__tests__/ducks/connectionSpec.js
parent8f1b763082d0d00bee0b1e97f9c8bfb740083c63 (diff)
downloadmitmproxy-97a00728a85a32ca6a8e98a991f6dcf28809e73b.tar.gz
mitmproxy-97a00728a85a32ca6a8e98a991f6dcf28809e73b.tar.bz2
mitmproxy-97a00728a85a32ca6a8e98a991f6dcf28809e73b.zip
[web] add connection tests
Diffstat (limited to 'web/src/js/__tests__/ducks/connectionSpec.js')
-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,
+ })
+ })
+
+})