aboutsummaryrefslogtreecommitdiffstats
path: root/app/__tests__
diff options
context:
space:
mode:
authorHsuan Lee <boczeratul@gmail.com>2019-04-08 15:17:20 +0800
committerHsuan Lee <boczeratul@gmail.com>2019-04-08 15:17:20 +0800
commit180942ed527a351c28cc2a418c1528c4e5aaa33e (patch)
treed76e9dba7a59fbb1ea5e9dd3a0f453239790b5d4 /app/__tests__
parenta5a621df50dee4bd472cb95dc6dfd824d4a48696 (diff)
downloaddexon-lottery-180942ed527a351c28cc2a418c1528c4e5aaa33e.tar
dexon-lottery-180942ed527a351c28cc2a418c1528c4e5aaa33e.tar.gz
dexon-lottery-180942ed527a351c28cc2a418c1528c4e5aaa33e.tar.bz2
dexon-lottery-180942ed527a351c28cc2a418c1528c4e5aaa33e.tar.lz
dexon-lottery-180942ed527a351c28cc2a418c1528c4e5aaa33e.tar.xz
dexon-lottery-180942ed527a351c28cc2a418c1528c4e5aaa33e.tar.zst
dexon-lottery-180942ed527a351c28cc2a418c1528c4e5aaa33e.zip
Add in webapp
Diffstat (limited to 'app/__tests__')
-rw-r--r--app/__tests__/i18n.test.js28
-rw-r--r--app/__tests__/reducers.test.js24
-rw-r--r--app/__tests__/store.test.js43
3 files changed, 95 insertions, 0 deletions
diff --git a/app/__tests__/i18n.test.js b/app/__tests__/i18n.test.js
new file mode 100644
index 0000000..6a4ff28
--- /dev/null
+++ b/app/__tests__/i18n.test.js
@@ -0,0 +1,28 @@
+import { formatTranslationMessages } from '../i18n';
+
+jest.mock('../translations/en.json', () => ({
+ message1: 'default message',
+ message2: 'default message 2',
+}));
+
+const esTranslationMessages = {
+ message1: 'mensaje predeterminado',
+ message2: '',
+};
+
+describe('formatTranslationMessages', () => {
+ it('should build only defaults when DEFAULT_LOCALE', () => {
+ const result = formatTranslationMessages('en', { a: 'a' });
+
+ expect(result).toEqual({ a: 'a' });
+ });
+
+ it('should combine default locale and current locale when not DEFAULT_LOCALE', () => {
+ const result = formatTranslationMessages('', esTranslationMessages);
+
+ expect(result).toEqual({
+ message1: 'mensaje predeterminado',
+ message2: 'default message 2',
+ });
+ });
+});
diff --git a/app/__tests__/reducers.test.js b/app/__tests__/reducers.test.js
new file mode 100644
index 0000000..fec9dcd
--- /dev/null
+++ b/app/__tests__/reducers.test.js
@@ -0,0 +1,24 @@
+/**
+ * Test route reducer
+ */
+
+import { fromJS } from 'immutable';
+import { LOCATION_CHANGE } from 'react-router-redux';
+import { routeReducer } from '../reducers';
+
+describe('route reducer', () => {
+ it('should return the initial state', () => {
+ const initialState = { foo: 'bar' };
+ expect(routeReducer(initialState, {})).toEqual(initialState);
+ });
+
+ it('should handle the location_change action correctly', () => {
+ const state = fromJS({ location: 'somewhere' });
+ const payload = 'elsewhere';
+ const action = { type: LOCATION_CHANGE, payload };
+
+ const expectedState = { location: payload };
+ const resultState = routeReducer(state, action).toJS();
+ expect(resultState).toEqual(expectedState);
+ });
+});
diff --git a/app/__tests__/store.test.js b/app/__tests__/store.test.js
new file mode 100644
index 0000000..f0fe7a7
--- /dev/null
+++ b/app/__tests__/store.test.js
@@ -0,0 +1,43 @@
+/**
+ * Test store addons
+ */
+
+import { browserHistory } from 'react-router-dom';
+import configureStore from '../configureStore';
+
+describe('configureStore', () => {
+ let store;
+
+ beforeAll(() => {
+ store = configureStore({}, browserHistory);
+ });
+
+ describe('injectedReducers', () => {
+ it('should contain an object for reducers', () => {
+ expect(typeof store.injectedReducers).toBe('object');
+ });
+ });
+
+ describe('injectedEpics', () => {
+ it('should contain an object for epics', () => {
+ expect(typeof store.injectedEpics).toBe('object');
+ });
+ });
+
+ describe('addEpic', () => {
+ it('should contain a hook for async epic injection', () => {
+ expect(typeof store.addEpic).toBe('function');
+ });
+ });
+});
+
+describe('configureStore params', () => {
+ it('should call window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__', () => {
+ /* eslint-disable no-underscore-dangle */
+ const compose = jest.fn();
+ window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ = () => compose;
+ configureStore(undefined, browserHistory);
+ expect(compose).toHaveBeenCalled();
+ /* eslint-enable */
+ });
+});