├── .babelrc
├── .eslintrc
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── docs
├── chai.html
├── expect.html
├── expectjs.html
├── gitbook
│ ├── app.js
│ ├── fonts
│ │ └── fontawesome
│ │ │ ├── FontAwesome.otf
│ │ │ ├── fontawesome-webfont.eot
│ │ │ ├── fontawesome-webfont.svg
│ │ │ ├── fontawesome-webfont.ttf
│ │ │ └── fontawesome-webfont.woff
│ ├── images
│ │ ├── apple-touch-icon-precomposed-152.png
│ │ └── favicon.ico
│ ├── plugins
│ │ ├── gitbook-plugin-fontsettings
│ │ │ ├── buttons.js
│ │ │ └── website.css
│ │ ├── gitbook-plugin-ga
│ │ │ └── plugin.js
│ │ ├── gitbook-plugin-highlight
│ │ │ ├── ebook.css
│ │ │ └── website.css
│ │ ├── gitbook-plugin-search
│ │ │ ├── lunr.min.js
│ │ │ ├── search.css
│ │ │ └── search.js
│ │ └── gitbook-plugin-sharing
│ │ │ └── buttons.js
│ └── style.css
├── index.html
├── installation.html
├── jasmine.html
├── javascript.html
├── jest.html
├── package.json
├── search_index.json
├── should.html
├── tape.html
└── what_it_does.html
├── documentation
├── README.md
├── SUMMARY.md
├── book.json
├── chai.md
├── expect.md
├── expectjs.md
├── installation.md
├── jasmine.md
├── javascript.md
├── jest.md
├── package.json
├── should.md
├── tape.md
└── what_it_does.md
├── package.json
├── src
├── actionWithInitialState.js
├── chai.js
├── expect.js
├── expectjs.js
├── index.js
├── jasmine.js
├── jest.js
├── package.json
└── should.js
└── test
├── chai
└── index.js
├── expect
└── index.js
├── expectjs
└── index.js
├── index.js
├── jasmine
├── index.js
└── jasmine.json
├── jest
├── index.js
├── jest.json
└── setupFramework.js
├── should
└── index.js
├── tape
└── index.js
└── testingData
├── actions.js
└── reducers.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | "es2015"
4 | ]
5 | }
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "airbnb-base",
3 | "parserOptions": {
4 | "ecmaVersion": 6,
5 | "sourceType": "module",
6 | "ecmaFeatures": {
7 | },
8 | },
9 | "env": {
10 | "es6": true,
11 | "mocha": true
12 | },
13 | "rules": {
14 | "arrow-body-style": ["error", "always"],
15 | "prefer-const": 1,
16 | "no-param-reassign": 0,
17 | "new-cap": 0,
18 | "comma-dangle": [2, "never"],
19 | "spaced-comment": [2, "always", { exceptions: ["*", "-"] }],
20 | "quote-props": [2, "consistent"],
21 | "no-underscore-dangle": ["error", { "allowAfterThis": true }]
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | logs
2 | *.log
3 | node_modules
4 | build
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - stable
5 | script:
6 | - npm run test
7 | - npm run prepublish
8 | branches:
9 | only:
10 | - master
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Dmitry Zaets
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # redux-actions-assertions
2 | Assertions for redux actions testing.
3 |
4 | This library adds assertions for [redux actions](http://redux.js.org/docs/advanced/AsyncActions.html) testing.
5 | It use [redux-mock-store](https://github.com/arnaudbenard/redux-mock-store) to mock redux store.
6 |
7 | [](https://travis-ci.org/redux-things/redux-actions-assertions)
8 | [](https://www.npmjs.com/package/redux-actions-assertions)
9 |
10 | ## Supported Assertion Frameworks/Libraries:
11 | - [chai](https://redux-things.github.io/redux-actions-assertions/chai.html)
12 | - [expect](https://redux-things.github.io/redux-actions-assertions/expect.html)
13 | - [expect.js](https://redux-things.github.io/redux-actions-assertions/expectjs.html)
14 | - [jasmine](https://redux-things.github.io/redux-actions-assertions/jasmine.html)
15 | - [jest](https://redux-things.github.io/redux-actions-assertions/jest.html)
16 | - [should](https://redux-things.github.io/redux-actions-assertions/should.html)
17 | - [tape](https://redux-things.github.io/redux-actions-assertions/tape.html)
18 | - [pure javascript assertion](https://redux-things.github.io/redux-actions-assertions/javascript.html)
19 |
20 | If you have not found assertion framework/library that you are using - please add comment into [this issue](https://github.com/dmitry-zaets/redux-actions-assertions/issues/3).
21 |
22 | ## What it does:
23 | - [Allows to avoid retesting nested action creators](#allows-to-avoid-retesting-nested-action-creators);
24 | - [Reduces repetitive code of test methods](#reduces-repetitive-code-of-test-methods);
25 | - [Simplifies initial setup](#simplifies-initial-setup);
26 |
27 | ### Allows to avoid retesting nested action creators
28 | It allows to test only actions that need to be tested.
29 |
30 | **Example:**
31 | We have two actions (A, B). Each one makes async http requests.
32 | Action A makes a request and if the result is successful it triggers Action B.
33 | Action B is also used as an independent action.
34 | Action B can be tested separately.
35 | Therefore, we don't need to test it again in Action A.
36 |
37 | Actions:
38 | ```javascript
39 | function actionA() {
40 | return dispatch => {
41 | dispatch(actionAStart());
42 | return api.getA().then(response => {
43 | dispatch(actionAFinish(response));
44 | dispatch(actionB());
45 | }).catch(err => {
46 | dispatch(actionAFailure(err));
47 | });
48 | };
49 | }
50 |
51 | function actionB() {
52 | return dispatch => {
53 | dispatch(actionBStart());
54 | return api.getB().then(response => {
55 | dispatch(actionBFinish(response));
56 | }).catch(err => {
57 | dispatch(actionBFailure(err));
58 | });
59 | };
60 | }
61 | ```
62 |
63 | Without:
64 | ```javascript
65 | const expectedActions = [
66 | { type: action_a_start },
67 | { type: action_a_success },
68 | { type: action_b_start }, // retesting of action B
69 | { type: action_b_success } // retesting of action B];
70 | const store = mockStore({ todos: [] });
71 | store.dispatch(actionA()).then(() => {
72 | expect(store.getActions()).toEqual(expectedActions);
73 | }).then(done).catch(done);
74 | ```
75 |
76 | With:
77 | ```javascript
78 | expect(actionA()).withState({ todos: [] }).toDispatch([
79 | { type: action_a_start },
80 | { type: action_a_success },
81 | actionB() // just executing tested action
82 | ], done);
83 | ```
84 |
85 | ### Reduces repetitive code of test methods
86 | It reduces boilerplate of test methods and makes testing fluent.
87 |
88 | Without:
89 | ```javascript
90 | const store = mockStore(/* initial state */);
91 | const expectedActions = [
92 | { type: types.FETCH_TODOS_REQUEST },
93 | /* All expected triggered action objects */
94 | ];
95 | store.dispatch(fetchData()).then(() => {
96 | const actions = store.getActions();
97 | expect(actions).toEqual(expectedActions);
98 | }).then(done).catch(done);
99 | ```
100 |
101 | With:
102 | ```javascript
103 | const expectedActions = [
104 | /*All expected triggered action objects or action creator functions*/
105 | ];
106 | expect(fetchData()).toDispatchActions(expectedActions, done);
107 | ```
108 |
109 | With using customised store state:
110 | ```javascript
111 | expect(fetchData()).withState({/*custom state*/}).toDispatchActions(expectedActions, done);
112 | ```
113 |
114 | ### Simplifies initial setup
115 | It provides singe-time global configuration for middlewares and initial store state.
116 |
117 | Without:
118 | ```javascript
119 | const middlewares = [thunk];
120 | const mockStore = configureStore(middlewares);
121 | const store = mockStore({ /*initial store object*});
122 | ```
123 | With:
124 | ```javascript
125 | registerMiddlewares([ thunk ]);
126 | // to set custom initial state
127 | registerInitialStoreState(/*object of function*/);
128 | // to generate initial state of your application
129 | registerInitialStoreState(buildInitialStoreState(/*your root reducer*/));
130 | ```
131 |
132 | ## Installation
133 |
134 | Using [npm](https://www.npmjs.org/):
135 |
136 | $ npm install --save-dev redux-actions-assertions
137 |
138 | ### Redux middlewares registration
139 |
140 | ```js
141 | // using ES6 modules
142 | import { registerMiddlewares } from 'redux-actions-assertions';
143 |
144 | // using CommonJS modules
145 | var registerMiddlewares = require('redux-actions-assertions').registerMiddlewares;
146 |
147 | // registration
148 | registerMiddlewares([
149 | /* Here you need to list your middlewares */
150 | ]);
151 | ```
152 |
153 | ### Default initial store state registration
154 |
155 | **By using state object or function:**
156 | ```js
157 | // using ES6 modules
158 | import { registerInitialStoreState } from 'redux-actions-assertions';
159 |
160 | // using CommonJS modules
161 | var registerInitialStoreState = require('redux-actions-assertions').registerInitialStoreState;
162 |
163 | // registration
164 | registerInitialStoreState(/* default initial state object or function */);
165 | ```
166 | **By using your root reducer:**
167 | ```js
168 | // using ES6 modules
169 | import { buildInitialStoreState, registerInitialStoreState } from 'redux-actions-assertions';
170 |
171 | // using CommonJS modules
172 | var reduxActionsAssertions = require('redux-actions-assertions');
173 | var registerInitialStoreState = reduxActionsAssertions.registerInitialStoreState;
174 |
175 | // registration
176 | registerInitialStoreState(buildInitialStoreState(/* root reducer function */));
177 | ```
178 |
--------------------------------------------------------------------------------
/docs/expect.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | expect | Redux Actions Assertions
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
58 |
59 |
60 |
254 |
255 |
256 |
257 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 | Registration
276 |
277 | import { registerAssertions } from 'redux-actions-assertions/expect' ;
278 |
279 |
280 | var registerAssertions = require ('redux-actions-assertions/expect' ).registerAssertions;
281 |
282 |
283 | registerAssertions();
284 |
285 | Usage
286 | .toDispatchActions
287 |
288 | expect(action).toDispatchActions(expectedActions, callback)
289 |
290 | Asserts that when given action
is dispatched it will dispatch expectedActions
. action
can be plain object (action) or function (action creator). expectedActions
can be can be plain object (action) or function (action creator) or array of objects/functions.
291 | expect(myActionCreator())
292 | .toDispatchActions({ type: 'MY_ACTION_START' }, callback);
293 |
294 | .toNotDispatchActions
295 |
296 | expect(action).toNotDispatchActions(expectedActions, callback)
297 |
298 | Asserts that when given action
is dispatched it will not dispatch expectedActions
. action
can be plain object (action) or function (action creator). expectedActions
can be can be plain object (action) or function (action creator) or array of objects/functions.
299 | expect(myActionCreator())
300 | .toNotDispatchActions({ type: 'MY_ACTION_START' }, callback);
301 |
302 | .withState
303 |
304 | expect(action).withState(state).toDispatchActions(expectedActions, callback)
305 |
306 | Asserts that store initialised with state
before action
is dispatched.
307 | expect(myActionCreator())
308 | .withState({property: 'value' })
309 | .toDispatchActions([{ type: 'MY_ACTION_START' }, finishActionCreator()], callback);
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
358 |
359 |
360 |
361 |
362 |
363 |
--------------------------------------------------------------------------------
/docs/expectjs.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | expect.js | Redux Actions Assertions
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
58 |
59 |
60 |
254 |
255 |
256 |
257 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 | Registration
276 |
277 | import { registerAssertions } from 'redux-actions-assertions/expectjs' ;
278 |
279 |
280 | var registerAssertions = require ('redux-actions-assertions/expectjs' ).registerAssertions;
281 |
282 |
283 | registerAssertions();
284 |
285 | Usage
286 | .dispatchActions
287 |
288 | expect(action).to.dispatchActions(expectedActions, callback)
289 |
290 | Asserts that when given action
is dispatched it will dispatch expectedActions
. action
can be plain object (action) or function (action creator). expectedActions
can be can be plain object (action) or function (action creator) or array of objects/functions.
291 | expect(myActionCreator())
292 | .to.dispatchActions({ type: 'MY_ACTION_START' }, callback);
293 |
294 | .not.dispatchActions
295 |
296 | expect(action).not.to.dispatchActions(expectedActions, callback)
297 | expect(action).to.not.dispatchActions(expectedActions, callback)
298 |
299 | Asserts that when given action
is dispatched it will not dispatch expectedActions
. action
can be plain object (action) or function (action creator). expectedActions
can be can be plain object (action) or function (action creator) or array of objects/functions.
300 | expect(myActionCreator())
301 | .not.to.dispatchActions({ type: 'MY_ACTION_START' }, callback);
302 |
303 | expect(myActionCreator())
304 | .to.not.dispatchActions({ type: 'MY_ACTION_START' }, callback);
305 |
306 | .withState
307 |
308 | expect(action).withState(state).to.dispatchActions(expectedActions, callback)
309 |
310 | Asserts that store initialised with state
before action
is dispatched.
311 | expect(myActionCreator())
312 | .withState({ property: 'value' })
313 | .to.dispatchActions([{ type: 'MY_ACTION_START' }, finishActionCreator()], callback);
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
362 |
363 |
364 |
365 |
366 |
367 |
--------------------------------------------------------------------------------
/docs/gitbook/fonts/fontawesome/FontAwesome.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redux-things/redux-actions-assertions/e8cb335cda4428e3970d231c6de3756de96f2c86/docs/gitbook/fonts/fontawesome/FontAwesome.otf
--------------------------------------------------------------------------------
/docs/gitbook/fonts/fontawesome/fontawesome-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redux-things/redux-actions-assertions/e8cb335cda4428e3970d231c6de3756de96f2c86/docs/gitbook/fonts/fontawesome/fontawesome-webfont.eot
--------------------------------------------------------------------------------
/docs/gitbook/fonts/fontawesome/fontawesome-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redux-things/redux-actions-assertions/e8cb335cda4428e3970d231c6de3756de96f2c86/docs/gitbook/fonts/fontawesome/fontawesome-webfont.ttf
--------------------------------------------------------------------------------
/docs/gitbook/fonts/fontawesome/fontawesome-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redux-things/redux-actions-assertions/e8cb335cda4428e3970d231c6de3756de96f2c86/docs/gitbook/fonts/fontawesome/fontawesome-webfont.woff
--------------------------------------------------------------------------------
/docs/gitbook/images/apple-touch-icon-precomposed-152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redux-things/redux-actions-assertions/e8cb335cda4428e3970d231c6de3756de96f2c86/docs/gitbook/images/apple-touch-icon-precomposed-152.png
--------------------------------------------------------------------------------
/docs/gitbook/images/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redux-things/redux-actions-assertions/e8cb335cda4428e3970d231c6de3756de96f2c86/docs/gitbook/images/favicon.ico
--------------------------------------------------------------------------------
/docs/gitbook/plugins/gitbook-plugin-fontsettings/buttons.js:
--------------------------------------------------------------------------------
1 | require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
2 | var fontState;
3 |
4 | var THEMES = {
5 | "white": 0,
6 | "sepia": 1,
7 | "night": 2
8 | };
9 |
10 | var FAMILY = {
11 | "serif": 0,
12 | "sans": 1
13 | };
14 |
15 | // Save current font settings
16 | function saveFontSettings() {
17 | gitbook.storage.set("fontState", fontState);
18 | update();
19 | }
20 |
21 | // Increase font size
22 | function enlargeFontSize(e) {
23 | e.preventDefault();
24 | if (fontState.size >= 4) return;
25 |
26 | fontState.size++;
27 | saveFontSettings();
28 | };
29 |
30 | // Decrease font size
31 | function reduceFontSize(e) {
32 | e.preventDefault();
33 | if (fontState.size <= 0) return;
34 |
35 | fontState.size--;
36 | saveFontSettings();
37 | };
38 |
39 | // Change font family
40 | function changeFontFamily(index, e) {
41 | e.preventDefault();
42 |
43 | fontState.family = index;
44 | saveFontSettings();
45 | };
46 |
47 | // Change type of color
48 | function changeColorTheme(index, e) {
49 | e.preventDefault();
50 |
51 | var $book = $(".book");
52 |
53 | if (fontState.theme !== 0)
54 | $book.removeClass("color-theme-"+fontState.theme);
55 |
56 | fontState.theme = index;
57 | if (fontState.theme !== 0)
58 | $book.addClass("color-theme-"+fontState.theme);
59 |
60 | saveFontSettings();
61 | };
62 |
63 | function update() {
64 | var $book = gitbook.state.$book;
65 |
66 | $(".font-settings .font-family-list li").removeClass("active");
67 | $(".font-settings .font-family-list li:nth-child("+(fontState.family+1)+")").addClass("active");
68 |
69 | $book[0].className = $book[0].className.replace(/\bfont-\S+/g, '');
70 | $book.addClass("font-size-"+fontState.size);
71 | $book.addClass("font-family-"+fontState.family);
72 |
73 | if(fontState.theme !== 0) {
74 | $book[0].className = $book[0].className.replace(/\bcolor-theme-\S+/g, '');
75 | $book.addClass("color-theme-"+fontState.theme);
76 | }
77 | };
78 |
79 | function init(config) {
80 | var $bookBody, $book;
81 |
82 | //Find DOM elements.
83 | $book = gitbook.state.$book;
84 | $bookBody = $book.find(".book-body");
85 |
86 | // Instantiate font state object
87 | fontState = gitbook.storage.get("fontState", {
88 | size: config.size || 2,
89 | family: FAMILY[config.family || "sans"],
90 | theme: THEMES[config.theme || "white"]
91 | });
92 |
93 | update();
94 | };
95 |
96 |
97 | gitbook.events.bind("start", function(e, config) {
98 | var opts = config.fontsettings;
99 |
100 | // Create buttons in toolbar
101 | gitbook.toolbar.createButton({
102 | icon: 'fa fa-font',
103 | label: 'Font Settings',
104 | className: 'font-settings',
105 | dropdown: [
106 | [
107 | {
108 | text: 'A',
109 | className: 'font-reduce',
110 | onClick: reduceFontSize
111 | },
112 | {
113 | text: 'A',
114 | className: 'font-enlarge',
115 | onClick: enlargeFontSize
116 | }
117 | ],
118 | [
119 | {
120 | text: 'Serif',
121 | onClick: _.partial(changeFontFamily, 0)
122 | },
123 | {
124 | text: 'Sans',
125 | onClick: _.partial(changeFontFamily, 1)
126 | }
127 | ],
128 | [
129 | {
130 | text: 'White',
131 | onClick: _.partial(changeColorTheme, 0)
132 | },
133 | {
134 | text: 'Sepia',
135 | onClick: _.partial(changeColorTheme, 1)
136 | },
137 | {
138 | text: 'Night',
139 | onClick: _.partial(changeColorTheme, 2)
140 | }
141 | ]
142 | ]
143 | });
144 |
145 |
146 | // Init current settings
147 | init(opts);
148 | });
149 | });
150 |
151 |
152 |
--------------------------------------------------------------------------------
/docs/gitbook/plugins/gitbook-plugin-fontsettings/website.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Theme 1
3 | */
4 | .color-theme-1 .dropdown-menu {
5 | background-color: #111111;
6 | border-color: #7e888b;
7 | }
8 | .color-theme-1 .dropdown-menu .dropdown-caret .caret-inner {
9 | border-bottom: 9px solid #111111;
10 | }
11 | .color-theme-1 .dropdown-menu .buttons {
12 | border-color: #7e888b;
13 | }
14 | .color-theme-1 .dropdown-menu .button {
15 | color: #afa790;
16 | }
17 | .color-theme-1 .dropdown-menu .button:hover {
18 | color: #73553c;
19 | }
20 | /*
21 | * Theme 2
22 | */
23 | .color-theme-2 .dropdown-menu {
24 | background-color: #2d3143;
25 | border-color: #272a3a;
26 | }
27 | .color-theme-2 .dropdown-menu .dropdown-caret .caret-inner {
28 | border-bottom: 9px solid #2d3143;
29 | }
30 | .color-theme-2 .dropdown-menu .buttons {
31 | border-color: #272a3a;
32 | }
33 | .color-theme-2 .dropdown-menu .button {
34 | color: #62677f;
35 | }
36 | .color-theme-2 .dropdown-menu .button:hover {
37 | color: #f4f4f5;
38 | }
39 | .book .book-header .font-settings .font-enlarge {
40 | line-height: 30px;
41 | font-size: 1.4em;
42 | }
43 | .book .book-header .font-settings .font-reduce {
44 | line-height: 30px;
45 | font-size: 1em;
46 | }
47 | .book.color-theme-1 .book-body {
48 | color: #704214;
49 | background: #f3eacb;
50 | }
51 | .book.color-theme-1 .book-body .page-wrapper .page-inner section {
52 | background: #f3eacb;
53 | }
54 | .book.color-theme-2 .book-body {
55 | color: #bdcadb;
56 | background: #1c1f2b;
57 | }
58 | .book.color-theme-2 .book-body .page-wrapper .page-inner section {
59 | background: #1c1f2b;
60 | }
61 | .book.font-size-0 .book-body .page-inner section {
62 | font-size: 1.2rem;
63 | }
64 | .book.font-size-1 .book-body .page-inner section {
65 | font-size: 1.4rem;
66 | }
67 | .book.font-size-2 .book-body .page-inner section {
68 | font-size: 1.6rem;
69 | }
70 | .book.font-size-3 .book-body .page-inner section {
71 | font-size: 2.2rem;
72 | }
73 | .book.font-size-4 .book-body .page-inner section {
74 | font-size: 4rem;
75 | }
76 | .book.font-family-0 {
77 | font-family: Georgia, serif;
78 | }
79 | .book.font-family-1 {
80 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
81 | }
82 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal {
83 | color: #704214;
84 | }
85 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal a {
86 | color: inherit;
87 | }
88 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h1,
89 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h2,
90 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h3,
91 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h4,
92 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h5,
93 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h6 {
94 | color: inherit;
95 | }
96 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h1,
97 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h2 {
98 | border-color: inherit;
99 | }
100 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h6 {
101 | color: inherit;
102 | }
103 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal hr {
104 | background-color: inherit;
105 | }
106 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal blockquote {
107 | border-color: inherit;
108 | }
109 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre,
110 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code {
111 | background: #fdf6e3;
112 | color: #657b83;
113 | border-color: #f8df9c;
114 | }
115 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal .highlight {
116 | background-color: inherit;
117 | }
118 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table th,
119 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table td {
120 | border-color: #f5d06c;
121 | }
122 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table tr {
123 | color: inherit;
124 | background-color: #fdf6e3;
125 | border-color: #444444;
126 | }
127 | .book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table tr:nth-child(2n) {
128 | background-color: #fbeecb;
129 | }
130 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal {
131 | color: #bdcadb;
132 | }
133 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal a {
134 | color: #3eb1d0;
135 | }
136 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h1,
137 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h2,
138 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h3,
139 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h4,
140 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h5,
141 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h6 {
142 | color: #fffffa;
143 | }
144 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h1,
145 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h2 {
146 | border-color: #373b4e;
147 | }
148 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h6 {
149 | color: #373b4e;
150 | }
151 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal hr {
152 | background-color: #373b4e;
153 | }
154 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal blockquote {
155 | border-color: #373b4e;
156 | }
157 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre,
158 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code {
159 | color: #9dbed8;
160 | background: #2d3143;
161 | border-color: #2d3143;
162 | }
163 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal .highlight {
164 | background-color: #282a39;
165 | }
166 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table th,
167 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table td {
168 | border-color: #3b3f54;
169 | }
170 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table tr {
171 | color: #b6c2d2;
172 | background-color: #2d3143;
173 | border-color: #3b3f54;
174 | }
175 | .book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table tr:nth-child(2n) {
176 | background-color: #35394b;
177 | }
178 | .book.color-theme-1 .book-header {
179 | color: #afa790;
180 | background: transparent;
181 | }
182 | .book.color-theme-1 .book-header .btn {
183 | color: #afa790;
184 | }
185 | .book.color-theme-1 .book-header .btn:hover {
186 | color: #73553c;
187 | background: none;
188 | }
189 | .book.color-theme-1 .book-header h1 {
190 | color: #704214;
191 | }
192 | .book.color-theme-2 .book-header {
193 | color: #7e888b;
194 | background: transparent;
195 | }
196 | .book.color-theme-2 .book-header .btn {
197 | color: #3b3f54;
198 | }
199 | .book.color-theme-2 .book-header .btn:hover {
200 | color: #fffff5;
201 | background: none;
202 | }
203 | .book.color-theme-2 .book-header h1 {
204 | color: #bdcadb;
205 | }
206 | .book.color-theme-1 .book-body .navigation {
207 | color: #afa790;
208 | }
209 | .book.color-theme-1 .book-body .navigation:hover {
210 | color: #73553c;
211 | }
212 | .book.color-theme-2 .book-body .navigation {
213 | color: #383f52;
214 | }
215 | .book.color-theme-2 .book-body .navigation:hover {
216 | color: #fffff5;
217 | }
218 | /*
219 | * Theme 1
220 | */
221 | .book.color-theme-1 .book-summary {
222 | color: #afa790;
223 | background: #111111;
224 | border-right: 1px solid rgba(0, 0, 0, 0.07);
225 | }
226 | .book.color-theme-1 .book-summary .book-search {
227 | background: transparent;
228 | }
229 | .book.color-theme-1 .book-summary .book-search input,
230 | .book.color-theme-1 .book-summary .book-search input:focus {
231 | border: 1px solid transparent;
232 | }
233 | .book.color-theme-1 .book-summary ul.summary li.divider {
234 | background: #7e888b;
235 | box-shadow: none;
236 | }
237 | .book.color-theme-1 .book-summary ul.summary li i.fa-check {
238 | color: #33cc33;
239 | }
240 | .book.color-theme-1 .book-summary ul.summary li.done > a {
241 | color: #877f6a;
242 | }
243 | .book.color-theme-1 .book-summary ul.summary li a,
244 | .book.color-theme-1 .book-summary ul.summary li span {
245 | color: #877f6a;
246 | background: transparent;
247 | font-weight: normal;
248 | }
249 | .book.color-theme-1 .book-summary ul.summary li.active > a,
250 | .book.color-theme-1 .book-summary ul.summary li a:hover {
251 | color: #704214;
252 | background: transparent;
253 | font-weight: normal;
254 | }
255 | /*
256 | * Theme 2
257 | */
258 | .book.color-theme-2 .book-summary {
259 | color: #bcc1d2;
260 | background: #2d3143;
261 | border-right: none;
262 | }
263 | .book.color-theme-2 .book-summary .book-search {
264 | background: transparent;
265 | }
266 | .book.color-theme-2 .book-summary .book-search input,
267 | .book.color-theme-2 .book-summary .book-search input:focus {
268 | border: 1px solid transparent;
269 | }
270 | .book.color-theme-2 .book-summary ul.summary li.divider {
271 | background: #272a3a;
272 | box-shadow: none;
273 | }
274 | .book.color-theme-2 .book-summary ul.summary li i.fa-check {
275 | color: #33cc33;
276 | }
277 | .book.color-theme-2 .book-summary ul.summary li.done > a {
278 | color: #62687f;
279 | }
280 | .book.color-theme-2 .book-summary ul.summary li a,
281 | .book.color-theme-2 .book-summary ul.summary li span {
282 | color: #c1c6d7;
283 | background: transparent;
284 | font-weight: 600;
285 | }
286 | .book.color-theme-2 .book-summary ul.summary li.active > a,
287 | .book.color-theme-2 .book-summary ul.summary li a:hover {
288 | color: #f4f4f5;
289 | background: #252737;
290 | font-weight: 600;
291 | }
292 |
--------------------------------------------------------------------------------
/docs/gitbook/plugins/gitbook-plugin-ga/plugin.js:
--------------------------------------------------------------------------------
1 | require(["gitbook"], function(gitbook) {
2 | // Load analytics.js
3 | gitbook.events.bind("start", function(e, config) {
4 | (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
5 | (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
6 | m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
7 | })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
8 |
9 | var cfg = config.ga;
10 | ga('create', cfg.token, cfg.configuration);
11 | });
12 |
13 | // Notify pageview
14 | gitbook.events.bind("page.change", function() {
15 | ga('send', 'pageview', window.location.pathname+window.location.search);
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/docs/gitbook/plugins/gitbook-plugin-highlight/ebook.css:
--------------------------------------------------------------------------------
1 | pre,
2 | code {
3 | /* http://jmblog.github.io/color-themes-for-highlightjs */
4 | /* Tomorrow Comment */
5 | /* Tomorrow Red */
6 | /* Tomorrow Orange */
7 | /* Tomorrow Yellow */
8 | /* Tomorrow Green */
9 | /* Tomorrow Aqua */
10 | /* Tomorrow Blue */
11 | /* Tomorrow Purple */
12 | }
13 | pre .hljs-comment,
14 | code .hljs-comment,
15 | pre .hljs-title,
16 | code .hljs-title {
17 | color: #8e908c;
18 | }
19 | pre .hljs-variable,
20 | code .hljs-variable,
21 | pre .hljs-attribute,
22 | code .hljs-attribute,
23 | pre .hljs-tag,
24 | code .hljs-tag,
25 | pre .hljs-regexp,
26 | code .hljs-regexp,
27 | pre .ruby .hljs-constant,
28 | code .ruby .hljs-constant,
29 | pre .xml .hljs-tag .hljs-title,
30 | code .xml .hljs-tag .hljs-title,
31 | pre .xml .hljs-pi,
32 | code .xml .hljs-pi,
33 | pre .xml .hljs-doctype,
34 | code .xml .hljs-doctype,
35 | pre .html .hljs-doctype,
36 | code .html .hljs-doctype,
37 | pre .css .hljs-id,
38 | code .css .hljs-id,
39 | pre .css .hljs-class,
40 | code .css .hljs-class,
41 | pre .css .hljs-pseudo,
42 | code .css .hljs-pseudo {
43 | color: #c82829;
44 | }
45 | pre .hljs-number,
46 | code .hljs-number,
47 | pre .hljs-preprocessor,
48 | code .hljs-preprocessor,
49 | pre .hljs-pragma,
50 | code .hljs-pragma,
51 | pre .hljs-built_in,
52 | code .hljs-built_in,
53 | pre .hljs-literal,
54 | code .hljs-literal,
55 | pre .hljs-params,
56 | code .hljs-params,
57 | pre .hljs-constant,
58 | code .hljs-constant {
59 | color: #f5871f;
60 | }
61 | pre .ruby .hljs-class .hljs-title,
62 | code .ruby .hljs-class .hljs-title,
63 | pre .css .hljs-rules .hljs-attribute,
64 | code .css .hljs-rules .hljs-attribute {
65 | color: #eab700;
66 | }
67 | pre .hljs-string,
68 | code .hljs-string,
69 | pre .hljs-value,
70 | code .hljs-value,
71 | pre .hljs-inheritance,
72 | code .hljs-inheritance,
73 | pre .hljs-header,
74 | code .hljs-header,
75 | pre .ruby .hljs-symbol,
76 | code .ruby .hljs-symbol,
77 | pre .xml .hljs-cdata,
78 | code .xml .hljs-cdata {
79 | color: #718c00;
80 | }
81 | pre .css .hljs-hexcolor,
82 | code .css .hljs-hexcolor {
83 | color: #3e999f;
84 | }
85 | pre .hljs-function,
86 | code .hljs-function,
87 | pre .python .hljs-decorator,
88 | code .python .hljs-decorator,
89 | pre .python .hljs-title,
90 | code .python .hljs-title,
91 | pre .ruby .hljs-function .hljs-title,
92 | code .ruby .hljs-function .hljs-title,
93 | pre .ruby .hljs-title .hljs-keyword,
94 | code .ruby .hljs-title .hljs-keyword,
95 | pre .perl .hljs-sub,
96 | code .perl .hljs-sub,
97 | pre .javascript .hljs-title,
98 | code .javascript .hljs-title,
99 | pre .coffeescript .hljs-title,
100 | code .coffeescript .hljs-title {
101 | color: #4271ae;
102 | }
103 | pre .hljs-keyword,
104 | code .hljs-keyword,
105 | pre .javascript .hljs-function,
106 | code .javascript .hljs-function {
107 | color: #8959a8;
108 | }
109 | pre .hljs,
110 | code .hljs {
111 | display: block;
112 | background: white;
113 | color: #4d4d4c;
114 | padding: 0.5em;
115 | }
116 | pre .coffeescript .javascript,
117 | code .coffeescript .javascript,
118 | pre .javascript .xml,
119 | code .javascript .xml,
120 | pre .tex .hljs-formula,
121 | code .tex .hljs-formula,
122 | pre .xml .javascript,
123 | code .xml .javascript,
124 | pre .xml .vbscript,
125 | code .xml .vbscript,
126 | pre .xml .css,
127 | code .xml .css,
128 | pre .xml .hljs-cdata,
129 | code .xml .hljs-cdata {
130 | opacity: 0.5;
131 | }
132 |
--------------------------------------------------------------------------------
/docs/gitbook/plugins/gitbook-plugin-search/lunr.min.js:
--------------------------------------------------------------------------------
1 | /**
2 | * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 0.5.12
3 | * Copyright (C) 2015 Oliver Nightingale
4 | * MIT Licensed
5 | * @license
6 | */
7 | !function(){var t=function(e){var n=new t.Index;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),e&&e.call(n,n),n};t.version="0.5.12",t.utils={},t.utils.warn=function(t){return function(e){t.console&&console.warn&&console.warn(e)}}(this),t.EventEmitter=function(){this.events={}},t.EventEmitter.prototype.addListener=function(){var t=Array.prototype.slice.call(arguments),e=t.pop(),n=t;if("function"!=typeof e)throw new TypeError("last argument must be a function");n.forEach(function(t){this.hasHandler(t)||(this.events[t]=[]),this.events[t].push(e)},this)},t.EventEmitter.prototype.removeListener=function(t,e){if(this.hasHandler(t)){var n=this.events[t].indexOf(e);this.events[t].splice(n,1),this.events[t].length||delete this.events[t]}},t.EventEmitter.prototype.emit=function(t){if(this.hasHandler(t)){var e=Array.prototype.slice.call(arguments,1);this.events[t].forEach(function(t){t.apply(void 0,e)})}},t.EventEmitter.prototype.hasHandler=function(t){return t in this.events},t.tokenizer=function(t){return arguments.length&&null!=t&&void 0!=t?Array.isArray(t)?t.map(function(t){return t.toLowerCase()}):t.toString().trim().toLowerCase().split(/[\s\-]+/):[]},t.Pipeline=function(){this._stack=[]},t.Pipeline.registeredFunctions={},t.Pipeline.registerFunction=function(e,n){n in this.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[e.label]=e},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(e){var i=t.Pipeline.registeredFunctions[e];if(!i)throw new Error("Cannot load un-registered function: "+e);n.add(i)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){t.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._stack.indexOf(e);if(-1==i)throw new Error("Cannot find existingFn");i+=1,this._stack.splice(i,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._stack.indexOf(e);if(-1==i)throw new Error("Cannot find existingFn");this._stack.splice(i,0,n)},t.Pipeline.prototype.remove=function(t){var e=this._stack.indexOf(t);-1!=e&&this._stack.splice(e,1)},t.Pipeline.prototype.run=function(t){for(var e=[],n=t.length,i=this._stack.length,o=0;n>o;o++){for(var r=t[o],s=0;i>s&&(r=this._stack[s](r,o,t),void 0!==r);s++);void 0!==r&&e.push(r)}return e},t.Pipeline.prototype.reset=function(){this._stack=[]},t.Pipeline.prototype.toJSON=function(){return this._stack.map(function(e){return t.Pipeline.warnIfFunctionNotRegistered(e),e.label})},t.Vector=function(){this._magnitude=null,this.list=void 0,this.length=0},t.Vector.Node=function(t,e,n){this.idx=t,this.val=e,this.next=n},t.Vector.prototype.insert=function(e,n){this._magnitude=void 0;var i=this.list;if(!i)return this.list=new t.Vector.Node(e,n,i),this.length++;if(en.idx?n=n.next:(i+=e.val*n.val,e=e.next,n=n.next);return i},t.Vector.prototype.similarity=function(t){return this.dot(t)/(this.magnitude()*t.magnitude())},t.SortedSet=function(){this.length=0,this.elements=[]},t.SortedSet.load=function(t){var e=new this;return e.elements=t,e.length=t.length,e},t.SortedSet.prototype.add=function(){var t,e;for(t=0;t1;){if(r===t)return o;t>r&&(e=o),r>t&&(n=o),i=n-e,o=e+Math.floor(i/2),r=this.elements[o]}return r===t?o:-1},t.SortedSet.prototype.locationFor=function(t){for(var e=0,n=this.elements.length,i=n-e,o=e+Math.floor(i/2),r=this.elements[o];i>1;)t>r&&(e=o),r>t&&(n=o),i=n-e,o=e+Math.floor(i/2),r=this.elements[o];return r>t?o:t>r?o+1:void 0},t.SortedSet.prototype.intersect=function(e){for(var n=new t.SortedSet,i=0,o=0,r=this.length,s=e.length,a=this.elements,h=e.elements;;){if(i>r-1||o>s-1)break;a[i]!==h[o]?a[i]h[o]&&o++:(n.add(a[i]),i++,o++)}return n},t.SortedSet.prototype.clone=function(){var e=new t.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},t.SortedSet.prototype.union=function(t){var e,n,i;return this.length>=t.length?(e=this,n=t):(e=t,n=this),i=e.clone(),i.add.apply(i,n.toArray()),i},t.SortedSet.prototype.toJSON=function(){return this.toArray()},t.Index=function(){this._fields=[],this._ref="id",this.pipeline=new t.Pipeline,this.documentStore=new t.Store,this.tokenStore=new t.TokenStore,this.corpusTokens=new t.SortedSet,this.eventEmitter=new t.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))},t.Index.prototype.on=function(){var t=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,t)},t.Index.prototype.off=function(t,e){return this.eventEmitter.removeListener(t,e)},t.Index.load=function(e){e.version!==t.version&&t.utils.warn("version mismatch: current "+t.version+" importing "+e.version);var n=new this;return n._fields=e.fields,n._ref=e.ref,n.documentStore=t.Store.load(e.documentStore),n.tokenStore=t.TokenStore.load(e.tokenStore),n.corpusTokens=t.SortedSet.load(e.corpusTokens),n.pipeline=t.Pipeline.load(e.pipeline),n},t.Index.prototype.field=function(t,e){var e=e||{},n={name:t,boost:e.boost||1};return this._fields.push(n),this},t.Index.prototype.ref=function(t){return this._ref=t,this},t.Index.prototype.add=function(e,n){var i={},o=new t.SortedSet,r=e[this._ref],n=void 0===n?!0:n;this._fields.forEach(function(n){var r=this.pipeline.run(t.tokenizer(e[n.name]));i[n.name]=r,t.SortedSet.prototype.add.apply(o,r)},this),this.documentStore.set(r,o),t.SortedSet.prototype.add.apply(this.corpusTokens,o.toArray());for(var s=0;s0&&(i=1+Math.log(this.documentStore.length/n)),this._idfCache[e]=i},t.Index.prototype.search=function(e){var n=this.pipeline.run(t.tokenizer(e)),i=new t.Vector,o=[],r=this._fields.reduce(function(t,e){return t+e.boost},0),s=n.some(function(t){return this.tokenStore.has(t)},this);if(!s)return[];n.forEach(function(e,n,s){var a=1/s.length*this._fields.length*r,h=this,l=this.tokenStore.expand(e).reduce(function(n,o){var r=h.corpusTokens.indexOf(o),s=h.idf(o),l=1,u=new t.SortedSet;if(o!==e){var c=Math.max(3,o.length-e.length);l=1/Math.log(c)}return r>-1&&i.insert(r,a*s*l),Object.keys(h.tokenStore.get(o)).forEach(function(t){u.add(t)}),n.union(u)},new t.SortedSet);o.push(l)},this);var a=o.reduce(function(t,e){return t.intersect(e)});return a.map(function(t){return{ref:t,score:i.similarity(this.documentVector(t))}},this).sort(function(t,e){return e.score-t.score})},t.Index.prototype.documentVector=function(e){for(var n=this.documentStore.get(e),i=n.length,o=new t.Vector,r=0;i>r;r++){var s=n.elements[r],a=this.tokenStore.get(s)[e].tf,h=this.idf(s);o.insert(this.corpusTokens.indexOf(s),a*h)}return o},t.Index.prototype.toJSON=function(){return{version:t.version,fields:this._fields,ref:this._ref,documentStore:this.documentStore.toJSON(),tokenStore:this.tokenStore.toJSON(),corpusTokens:this.corpusTokens.toJSON(),pipeline:this.pipeline.toJSON()}},t.Index.prototype.use=function(t){var e=Array.prototype.slice.call(arguments,1);e.unshift(this),t.apply(this,e)},t.Store=function(){this.store={},this.length=0},t.Store.load=function(e){var n=new this;return n.length=e.length,n.store=Object.keys(e.store).reduce(function(n,i){return n[i]=t.SortedSet.load(e.store[i]),n},{}),n},t.Store.prototype.set=function(t,e){this.has(t)||this.length++,this.store[t]=e},t.Store.prototype.get=function(t){return this.store[t]},t.Store.prototype.has=function(t){return t in this.store},t.Store.prototype.remove=function(t){this.has(t)&&(delete this.store[t],this.length--)},t.Store.prototype.toJSON=function(){return{store:this.store,length:this.length}},t.stemmer=function(){var t={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},e={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},n="[^aeiou]",i="[aeiouy]",o=n+"[^aeiouy]*",r=i+"[aeiou]*",s="^("+o+")?"+r+o,a="^("+o+")?"+r+o+"("+r+")?$",h="^("+o+")?"+r+o+r+o,l="^("+o+")?"+i,u=new RegExp(s),c=new RegExp(h),f=new RegExp(a),d=new RegExp(l),p=/^(.+?)(ss|i)es$/,m=/^(.+?)([^s])s$/,v=/^(.+?)eed$/,y=/^(.+?)(ed|ing)$/,g=/.$/,S=/(at|bl|iz)$/,w=new RegExp("([^aeiouylsz])\\1$"),x=new RegExp("^"+o+i+"[^aeiouwxy]$"),k=/^(.+?[^aeiou])y$/,b=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,E=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,_=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,F=/^(.+?)(s|t)(ion)$/,O=/^(.+?)e$/,P=/ll$/,N=new RegExp("^"+o+i+"[^aeiouwxy]$"),T=function(n){var i,o,r,s,a,h,l;if(n.length<3)return n;if(r=n.substr(0,1),"y"==r&&(n=r.toUpperCase()+n.substr(1)),s=p,a=m,s.test(n)?n=n.replace(s,"$1$2"):a.test(n)&&(n=n.replace(a,"$1$2")),s=v,a=y,s.test(n)){var T=s.exec(n);s=u,s.test(T[1])&&(s=g,n=n.replace(s,""))}else if(a.test(n)){var T=a.exec(n);i=T[1],a=d,a.test(i)&&(n=i,a=S,h=w,l=x,a.test(n)?n+="e":h.test(n)?(s=g,n=n.replace(s,"")):l.test(n)&&(n+="e"))}if(s=k,s.test(n)){var T=s.exec(n);i=T[1],n=i+"i"}if(s=b,s.test(n)){var T=s.exec(n);i=T[1],o=T[2],s=u,s.test(i)&&(n=i+t[o])}if(s=E,s.test(n)){var T=s.exec(n);i=T[1],o=T[2],s=u,s.test(i)&&(n=i+e[o])}if(s=_,a=F,s.test(n)){var T=s.exec(n);i=T[1],s=c,s.test(i)&&(n=i)}else if(a.test(n)){var T=a.exec(n);i=T[1]+T[2],a=c,a.test(i)&&(n=i)}if(s=O,s.test(n)){var T=s.exec(n);i=T[1],s=c,a=f,h=N,(s.test(i)||a.test(i)&&!h.test(i))&&(n=i)}return s=P,a=c,s.test(n)&&a.test(n)&&(s=g,n=n.replace(s,"")),"y"==r&&(n=r.toLowerCase()+n.substr(1)),n};return T}(),t.Pipeline.registerFunction(t.stemmer,"stemmer"),t.stopWordFilter=function(e){return e&&t.stopWordFilter.stopWords[e]!==e?e:void 0},t.stopWordFilter.stopWords={a:"a",able:"able",about:"about",across:"across",after:"after",all:"all",almost:"almost",also:"also",am:"am",among:"among",an:"an",and:"and",any:"any",are:"are",as:"as",at:"at",be:"be",because:"because",been:"been",but:"but",by:"by",can:"can",cannot:"cannot",could:"could",dear:"dear",did:"did","do":"do",does:"does",either:"either","else":"else",ever:"ever",every:"every","for":"for",from:"from",get:"get",got:"got",had:"had",has:"has",have:"have",he:"he",her:"her",hers:"hers",him:"him",his:"his",how:"how",however:"however",i:"i","if":"if","in":"in",into:"into",is:"is",it:"it",its:"its",just:"just",least:"least",let:"let",like:"like",likely:"likely",may:"may",me:"me",might:"might",most:"most",must:"must",my:"my",neither:"neither",no:"no",nor:"nor",not:"not",of:"of",off:"off",often:"often",on:"on",only:"only",or:"or",other:"other",our:"our",own:"own",rather:"rather",said:"said",say:"say",says:"says",she:"she",should:"should",since:"since",so:"so",some:"some",than:"than",that:"that",the:"the",their:"their",them:"them",then:"then",there:"there",these:"these",they:"they","this":"this",tis:"tis",to:"to",too:"too",twas:"twas",us:"us",wants:"wants",was:"was",we:"we",were:"were",what:"what",when:"when",where:"where",which:"which","while":"while",who:"who",whom:"whom",why:"why",will:"will","with":"with",would:"would",yet:"yet",you:"you",your:"your"},t.Pipeline.registerFunction(t.stopWordFilter,"stopWordFilter"),t.trimmer=function(t){var e=t.replace(/^\W+/,"").replace(/\W+$/,"");return""===e?void 0:e},t.Pipeline.registerFunction(t.trimmer,"trimmer"),t.TokenStore=function(){this.root={docs:{}},this.length=0},t.TokenStore.load=function(t){var e=new this;return e.root=t.root,e.length=t.length,e},t.TokenStore.prototype.add=function(t,e,n){var n=n||this.root,i=t[0],o=t.slice(1);return i in n||(n[i]={docs:{}}),0===o.length?(n[i].docs[e.ref]=e,void(this.length+=1)):this.add(o,e,n[i])},t.TokenStore.prototype.has=function(t){if(!t)return!1;for(var e=this.root,n=0;n', {
41 | 'class': 'book-search',
42 | 'role': 'search'
43 | });
44 |
45 | $searchInput = $(' ', {
46 | 'type': 'text',
47 | 'class': 'form-control',
48 | 'val': value,
49 | 'placeholder': 'Type to search'
50 | });
51 |
52 | $searchInput.appendTo($searchForm);
53 | $searchForm.prependTo(gitbook.state.$book.find('.book-summary'));
54 | }
55 |
56 | // Return true if search is open
57 | function isSearchOpen() {
58 | return gitbook.state.$book.hasClass("with-search");
59 | }
60 |
61 | // Toggle the search
62 | function toggleSearch(_state) {
63 | if (isSearchOpen() === _state) return;
64 |
65 | gitbook.state.$book.toggleClass("with-search", _state);
66 |
67 | // If search bar is open: focus input
68 | if (isSearchOpen()) {
69 | gitbook.sidebar.toggle(true);
70 | $searchInput.focus();
71 | } else {
72 | $searchInput.blur();
73 | $searchInput.val("");
74 | gitbook.sidebar.filter(null);
75 | }
76 | }
77 |
78 | // Recover current search when page changed
79 | function recoverSearch() {
80 | var keyword = gitbook.storage.get("keyword", "");
81 |
82 | createForm(keyword);
83 |
84 | if (keyword.length > 0) {
85 | if(!isSearchOpen()) {
86 | toggleSearch();
87 | }
88 | gitbook.sidebar.filter(_.pluck(search(keyword), "path"));
89 | }
90 | };
91 |
92 |
93 | gitbook.events.bind("start", function(config) {
94 | // Pre-fetch search index and create the form
95 | fetchIndex();
96 | createForm();
97 |
98 | // Type in search bar
99 | $(document).on("keyup", ".book-search input", function(e) {
100 | var key = (e.keyCode ? e.keyCode : e.which);
101 | var q = $(this).val();
102 |
103 | if (key == 27) {
104 | e.preventDefault();
105 | toggleSearch(false);
106 | return;
107 | }
108 | if (q.length == 0) {
109 | gitbook.sidebar.filter(null);
110 | gitbook.storage.remove("keyword");
111 | } else {
112 | var results = search(q);
113 | gitbook.sidebar.filter(
114 | _.pluck(results, "path")
115 | );
116 | gitbook.storage.set("keyword", q);
117 | }
118 | });
119 |
120 | // Create the toggle search button
121 | gitbook.toolbar.createButton({
122 | icon: 'fa fa-search',
123 | label: 'Search',
124 | position: 'left',
125 | onClick: toggleSearch
126 | });
127 |
128 | // Bind keyboard to toggle search
129 | gitbook.keyboard.bind(['f'], toggleSearch)
130 | });
131 |
132 | gitbook.events.bind("page.change", recoverSearch);
133 | });
134 |
135 |
136 |
--------------------------------------------------------------------------------
/docs/gitbook/plugins/gitbook-plugin-sharing/buttons.js:
--------------------------------------------------------------------------------
1 | require(["gitbook", "lodash"], function(gitbook, _) {
2 | var SITES = {
3 | 'facebook': {
4 | 'label': 'Facebook',
5 | 'icon': 'fa fa-facebook',
6 | 'onClick': function(e) {
7 | e.preventDefault();
8 | window.open("http://www.facebook.com/sharer/sharer.php?s=100&p[url]="+encodeURIComponent(location.href));
9 | }
10 | },
11 | 'twitter': {
12 | 'label': 'Twitter',
13 | 'icon': 'fa fa-twitter',
14 | 'onClick': function(e) {
15 | e.preventDefault();
16 | window.open("http://twitter.com/home?status="+encodeURIComponent(document.title+" "+location.href));
17 | }
18 | },
19 | 'google': {
20 | 'label': 'Google+',
21 | 'icon': 'fa fa-google-plus',
22 | 'onClick': function(e) {
23 | e.preventDefault();
24 | window.open("https://plus.google.com/share?url="+encodeURIComponent(location.href));
25 | }
26 | },
27 | 'weibo': {
28 | 'label': 'Weibo',
29 | 'icon': 'fa fa-weibo',
30 | 'onClick': function(e) {
31 | e.preventDefault();
32 | window.open("http://service.weibo.com/share/share.php?content=utf-8&url="+encodeURIComponent(location.href)+"&title="+encodeURIComponent(document.title));
33 | }
34 | },
35 | 'instapaper': {
36 | 'label': 'Instapaper',
37 | 'icon': 'fa fa-instapaper',
38 | 'onClick': function(e) {
39 | e.preventDefault();
40 | window.open("http://www.instapaper.com/text?u="+encodeURIComponent(location.href));
41 | }
42 | },
43 | 'vk': {
44 | 'label': 'VK',
45 | 'icon': 'fa fa-vk',
46 | 'onClick': function(e) {
47 | e.preventDefault();
48 | window.open("http://vkontakte.ru/share.php?url="+encodeURIComponent(location.href));
49 | }
50 | }
51 | };
52 |
53 |
54 |
55 | gitbook.events.bind("start", function(e, config) {
56 | var opts = config.sharing;
57 |
58 | // Create dropdown menu
59 | var menu = _.chain(opts.all)
60 | .map(function(id) {
61 | var site = SITES[id];
62 |
63 | return {
64 | text: site.label,
65 | onClick: site.onClick
66 | };
67 | })
68 | .compact()
69 | .value();
70 |
71 | // Create main button with dropdown
72 | if (menu.length > 0) {
73 | gitbook.toolbar.createButton({
74 | icon: 'fa fa-share-alt',
75 | label: 'Share',
76 | position: 'right',
77 | dropdown: [menu]
78 | });
79 | }
80 |
81 | // Direct actions to share
82 | _.each(SITES, function(site, sideId) {
83 | if (!opts[sideId]) return;
84 |
85 | gitbook.toolbar.createButton({
86 | icon: site.icon,
87 | label: site.text,
88 | position: 'right',
89 | onClick: site.onClick
90 | });
91 | });
92 | });
93 | });
94 |
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Introduction | Redux Actions Assertions
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
56 |
57 |
58 |
252 |
253 |
254 |
255 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 | redux-actions-assertions
273 | Assertions for redux actions testing.
274 | This library adds assertions for redux actions testing. It use redux-mock-store to mock redux store.
275 |
276 |
277 | Supported Assertion Frameworks/Libraries:
278 |
285 | If you have not found assertion framework/library that you are using - please add comment into this issue .
286 | What it does:
287 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
337 |
338 |
339 |
340 |
341 |
342 |
--------------------------------------------------------------------------------
/docs/installation.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Installation | Redux Actions Assertions
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
58 |
59 |
60 |
254 |
255 |
256 |
257 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 | Installation
275 | Using npm :
276 | $ npm install --save-dev redux-actions-assertions
277 |
Redux middlewares registration
278 |
279 | import { registerMiddlewares } from 'redux-actions-assertions' ;
280 |
281 |
282 | var registerMiddlewares = require ('redux-actions-assertions' ).registerMiddlewares;
283 |
284 |
285 | registerMiddlewares([
286 |
287 | ]);
288 |
289 | Default initial store state registration
290 | By using state object or function:
291 |
292 | import { registerInitialStoreState } from 'redux-actions-assertions' ;
293 |
294 |
295 | var registerInitialStoreState = require ('redux-actions-assertions' ).registerInitialStoreState;
296 |
297 |
298 | registerInitialStoreState();
299 |
300 | By using your root reducer:
301 |
302 | import { buildInitialStoreState, registerInitialStoreState } from 'redux-actions-assertions' ;
303 |
304 |
305 | var reduxActionsAssertions = require ('redux-actions-assertions' );
306 | var registerInitialStoreState = reduxActionsAssertions.registerInitialStoreState;
307 |
308 |
309 | registerInitialStoreState(buildInitialStoreState());
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
358 |
359 |
360 |
361 |
362 |
363 |
--------------------------------------------------------------------------------
/docs/jasmine.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | jasmine | Redux Actions Assertions
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
58 |
59 |
60 |
254 |
255 |
256 |
257 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 | Registration
276 |
277 | import { registerAssertions } from 'redux-actions-assertions/jasmine' ;
278 |
279 |
280 | var registerAssertions = require ('redux-actions-assertions/jasmine' ).registerAssertions;
281 |
282 |
283 | beforeEach(registerAssertions);
284 |
285 | Usage
286 | .toDispatchActions
287 |
288 | expect(action).toDispatchActions(expectedActions, done)
289 |
290 | Asserts that when given action
is dispatched it will dispatch expectedActions
. action
can be plain object (action) or function (action creator). expectedActions
can be can be plain object (action) or function (action creator) or array of objects/functions.
291 | expect(myActionCreator())
292 | .toDispatchActions({ type: 'MY_ACTION_START' }, done);
293 |
294 | .not.toDispatchActions
295 |
296 | expect(action).not.toDispatchActions(expectedActions, done)
297 |
298 | Asserts that when given action
is dispatched it will not dispatch expectedActions
. action
can be plain object (action) or function (action creator). expectedActions
can be can be plain object (action) or function (action creator) or array of objects/functions.
299 | expect(myActionCreator())
300 | .not.toDispatchActions({ type: 'MY_ACTION_START' }, done);
301 |
302 | .toDispatchActionsWithState
303 |
304 | expect(action).toDispatchActionsWithState(state, expectedActions, done)
305 |
306 | Asserts that store initialised with state
before action
is dispatched.
307 | const state = {property: 'value' };
308 | const expectedActions = [{ type: 'MY_ACTION_START' }, finishActionCreator()];
309 | expect(myActionCreator())
310 | .toDispatchActionsWithState(state, expectedActions, done);
311 |
312 | You can also use it with .not
:
313 | expect(myActionCreator())
314 | .not.toDispatchActionsWithState(state, expectedActions, done);
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
363 |
364 |
365 |
366 |
367 |
368 |
--------------------------------------------------------------------------------
/docs/javascript.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | API Reference | Redux Actions Assertions
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
58 |
59 |
60 |
254 |
255 |
256 |
257 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 | javascript
275 | Registration
276 |
277 | import { assertions } from 'redux-actions-assertions' ;
278 |
279 |
280 | var assertions = require ('redux-actions-assertions' ).assertions;
281 |
282 |
283 | assertions.toDispatchActions()
284 | assertions.toNotDispatchActions()
285 | assertions.toDispatchActionsWithState();
286 | assertions.toNotDispatchActionsWithState();
287 |
288 | For plain javascript assertions you don't need to register anything. Just import assertions in your tests:
289 | Usage
290 | toDispatchActions
291 |
292 | toDispatchActions(action, expectedActions, callback)
293 |
294 | Asserts that when given action
is dispatched it will dispatch expectedActions
. action
can be plain object (action) or function (action creator). expectedActions
can be can be plain object (action) or function (action creator) or array of objects/functions.
295 | toDispatchActions(testActionCreator(), [{ type: 'MY_ACTION_START' }], callback);
296 |
297 | toNotDispatchActions
298 |
299 | toNotDispatchActions(action, expectedActions, callback)
300 |
301 | Asserts that when given action
is dispatched it will not dispatch expectedActions
. action
can be plain object (action) or function (action creator). expectedActions
can be can be plain object (action) or function (action creator) or array of objects/functions.
302 | toNotDispatchActions(testActionCreator(), [{ type: 'MY_ACTION_START' }], callback);
303 |
304 | toDispatchActionsWithState
305 |
306 | toDispatchActionsWithState(initialState, action, expectedActions, callback)
307 |
308 | Same as toDispatchActions
+ asserts that store initialised with state
before action
is dispatched.
309 | toDispatchActions({property: 'value' }, testActionCreator(), [{ type: 'MY_ACTION_START' }], callback);
310 |
311 | toNotDispatchActionsWithState
312 |
313 | toNotDispatchActionsWithState(initialState, action, expectedActions, callback)
314 |
315 | Same as toNotDispatchActions
+ asserts that store initialised with state
before action
is dispatched.
316 | toNotDispatchActions({property: 'value' }, testActionCreator(), [{ type: 'MY_ACTION_START' }], callback);
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
365 |
366 |
367 |
368 |
369 |
370 |
--------------------------------------------------------------------------------
/docs/jest.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | jest | Redux Actions Assertions
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
58 |
59 |
60 |
254 |
255 |
256 |
257 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 | Registration
276 |
277 |
278 | import { registerAssertions } from 'redux-actions-assertions/jest' ;
279 |
280 | beforeEach(registerAssertions);
281 |
282 | Usage
283 | .toDispatchActions
284 |
285 | expect(action).toDispatchActions(expectedActions, done)
286 |
287 | Asserts that when given action
is dispatched it will dispatch expectedActions
. action
can be plain object (action) or function (action creator). expectedActions
can be can be plain object (action) or function (action creator) or array of objects/functions.
288 | expect(myActionCreator())
289 | .toDispatchActions({ type: 'MY_ACTION_START' }, done);
290 |
291 | .toNotDispatchActions
292 |
293 | expect(action).toNotDispatchActions(expectedActions, done)
294 |
295 | Asserts that when given action
is dispatched it will not dispatch expectedActions
. action
can be plain object (action) or function (action creator). expectedActions
can be can be plain object (action) or function (action creator) or array of objects/functions.
296 | expect(myActionCreator())
297 | .toNotDispatchActions({ type: 'MY_ACTION_START' }, done);
298 |
299 | .toDispatchActionsWithState
300 |
301 | expect(action).toDispatchActionsWithState(state, expectedActions, done)
302 |
303 | Asserts that store initialised with state
before action
is dispatched.
304 | const state = {property: 'value' };
305 | const expectedActions = [{ type: 'MY_ACTION_START' }, finishActionCreator()];
306 | expect(myActionCreator())
307 | .toDispatchActionsWithState(state, expectedActions, done);
308 |
309 | You can also use its variant .toNotDispatchActionsWithState
:
310 | expect(myActionCreator())
311 | .toNotDispatchActionsWithState(state, expectedActions, done);
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
360 |
361 |
362 |
363 |
364 |
365 |
--------------------------------------------------------------------------------
/docs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "redux-actions-assertions-docs",
3 | "version": "0.0.1",
4 | "description": "Docs for redux-actions-assertions",
5 | "main": "index.js",
6 | "scripts": {
7 | "build": "gitbook install && gitbook build ./ ../docs"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "gitbook-plugin-ga": "^1.0.1"
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/docs/should.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | should | Redux Actions Assertions
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
58 |
59 |
60 |
254 |
255 |
256 |
257 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 | Registration
276 |
277 | import { registerAssertions } from 'redux-actions-assertions/should' ;
278 |
279 |
280 | var registerAssertions = require ('redux-actions-assertions/should' ).registerAssertions;
281 |
282 |
283 | registerAssertions();
284 |
285 | Usage
286 | .dispatchActions
287 |
288 | should(action).dispatchActions(expectedActions, callback)
289 | action.should.dispatchActions(expectedActions, callback)
290 |
291 | Asserts that when given action
is dispatched it will dispatch expectedActions
. action
can be plain object (action) or function (action creator). expectedActions
can be can be plain object (action) or function (action creator) or array of objects/functions.
292 | should(myActionCreator())
293 | .dispatchActions({ type: 'MY_ACTION_START' }, callback);
294 |
295 | myActionCreator().should
296 | .dispatchActions({ type: 'MY_ACTION_START' }, callback);
297 |
298 | .notDispatchActions
299 |
300 | should(action).notDispatchActions(expectedActions, callback)
301 | action.should.notDispatchActions(expectedActions, callback)
302 |
303 | Asserts that when given action
is dispatched it will not dispatch expectedActions
. action
can be plain object (action) or function (action creator). expectedActions
can be can be plain object (action) or function (action creator) or array of objects/functions.
304 | should(myActionCreator())
305 | .notDispatchActions({ type: 'MY_ACTION_START' }, callback);
306 |
307 | myActionCreator().should
308 | .notDispatchActions({ type: 'MY_ACTION_START' }, callback);
309 |
310 | .withState or with.state
311 |
312 | should(action).withState(state).dispatchActions(expectedActions, callback)
313 | should(action).with.state(state).dispatchActions(expectedActions, callback)
314 | action.should.withState(state).dispatchActions(expectedActions, callback)
315 | action.should.with.state(state).dispatchActions(expectedActions, callback)
316 |
317 | Asserts that store initialised with state
before action
is dispatched.
318 | should(myActionCreator())
319 | .withState({ property: 'value' })
320 | .dispatchActions({ type: 'MY_ACTION_START' }, callback);
321 |
322 | should(myActionCreator())
323 | .with.state({ property: 'value' })
324 | .dispatchActions({ type: 'MY_ACTION_START' }, callback);
325 |
326 | myActionCreator().should
327 | .withState({ property: 'value' })
328 | .dispatchActions({ type: 'MY_ACTION_START' }, callback);
329 |
330 | myActionCreator().should
331 | .with.state({ property: 'value' })
332 | .dispatchActions({ type: 'MY_ACTION_START' }, callback);
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
381 |
382 |
383 |
384 |
385 |
386 |
--------------------------------------------------------------------------------
/documentation/README.md:
--------------------------------------------------------------------------------
1 | # redux-actions-assertions
2 | Assertions for redux actions testing.
3 |
4 | This library adds assertions for [redux actions](http://redux.js.org/docs/advanced/AsyncActions.html) testing.
5 | It use [redux-mock-store](https://github.com/arnaudbenard/redux-mock-store) to mock redux store.
6 |
7 | [](https://travis-ci.org/redux-things/redux-actions-assertions)
8 | [](https://www.npmjs.com/package/redux-actions-assertions)
9 |
10 | ## Supported Assertion Frameworks/Libraries:
11 | - [chai](https://redux-things.github.io/redux-actions-assertions/chai.html)
12 | - [expect](https://redux-things.github.io/redux-actions-assertions/expect.html)
13 | - [expect.js](https://redux-things.github.io/redux-actions-assertions/expectjs.html)
14 | - [should](https://redux-things.github.io/redux-actions-assertions/should.html)
15 | - [pure javascript assertion](https://redux-things.github.io/redux-actions-assertions/javascript.html)
16 |
17 | If you have not found assertion framework/library that you are using - please add comment into [this issue](https://github.com/dmitry-zaets/redux-actions-assertions/issues/3).
18 |
19 | ## What it does:
20 | - [Allows to avoid retesting nested action creators](https://redux-things.github.io/redux-actions-assertions/what_it_does.html#allows-to-avoid-retesting-nested-action-creators);
21 | - [Reduces repetitive code of test methods](https://redux-things.github.io/redux-actions-assertions/what_it_does.html#reduces-repetitive-code-of-test-methods);
22 | - [Simplifies initial setup](https://redux-things.github.io/redux-actions-assertions/what_it_does.html#simplifies-initial-setup);
23 |
--------------------------------------------------------------------------------
/documentation/SUMMARY.md:
--------------------------------------------------------------------------------
1 | # Summary
2 |
3 | * [Introduction](README.md)
4 | * [What it does](what_it_does.md)
5 | * [Installation](installation.md)
6 | * [API Reference](javascript.md)
7 | * [javascript](javascript.md)
8 | * [chai](chai.md)
9 | * [expect](expect.md)
10 | * [expect.js](expectjs.md)
11 | * [jasmine](jasmine.md)
12 | * [jest](jest.md)
13 | * [should](should.md)
14 | * [tape](tape.md)
--------------------------------------------------------------------------------
/documentation/book.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "Redux Actions Assertions",
3 | "description": "Assertions for redux actions testing. This library adds assertions for redux actions testing.",
4 | "plugins": [ "ga" ],
5 | "pluginsConfig": {
6 | "ga": {
7 | "token": "UA-78823490-1"
8 | }
9 | },
10 | "links": {
11 | "home": null,
12 | "about": false,
13 | "issues": "https://github.com/redux-things/redux-actions-assertions/issues",
14 | "contribute": false,
15 | "sharing": {
16 | "google": false,
17 | "facebook": false,
18 | "twitter": false,
19 | "website": false
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/documentation/chai.md:
--------------------------------------------------------------------------------
1 | # [chai](https://github.com/chaijs/chai)
2 |
3 | ## Registration
4 |
5 | ```js
6 | // using ES6 modules
7 | import { registerAssertions } from 'redux-actions-assertions/chai';
8 |
9 | // using CommonJS modules
10 | var registerAssertions = require('redux-actions-assertions/chai').registerAssertions;
11 |
12 | // registration
13 | registerAssertions();
14 | ```
15 |
16 | ## Usage
17 |
18 | ### .to.dispatch.actions or assert.isDispatching
19 |
20 | > `expect(action).to.dispatch.actions(expectedActions, callback)`
21 |
22 | > `action.should.dispatch.actions(expectedActions, callback)`
23 |
24 | > `assert.isDispatching(action, expectedActions, callback)`
25 |
26 | Asserts that when given `action` is dispatched it will dispatch `expectedActions`. `action` can be plain object (action) or function (action creator). `expectedActions` can be can be plain object (action) or function (action creator) or array of objects/functions.
27 |
28 | ```js
29 | expect(myActionCreator())
30 | .to.dispatch.actions({ type: 'MY_ACTION_START' }, callback);
31 |
32 | myActionCreator()
33 | .should.dispatch.actions({ type: 'MY_ACTION_START' }, callback);
34 |
35 | assert.isDispatching(
36 | myActionCreator(),
37 | { type: 'MY_ACTION_START' },
38 | callback
39 | );
40 | ```
41 |
42 | ### .not.to.dispatch.actions or .to.not.dispatch.actions or assert.isNotDispatching
43 |
44 | > `expect(action).not.to.dispatch.actions(expectedActions, callback)`
45 | > `expect(action).to.not.dispatch.actions(expectedActions, callback)`
46 |
47 | > `action.should.not.dispatch.actions(expectedActions, callback)`
48 |
49 | > `assert.isNotDispatching(action, expectedActions, callback)`
50 |
51 | Asserts that when given `action` is dispatched it will not dispatch `expectedActions`. `action` can be plain object (action) or function (action creator). `expectedActions` can be can be plain object (action) or function (action creator) or array of objects/functions.
52 |
53 | ```js
54 | expect(myActionCreator())
55 | .not.to.dispatch.actions({ type: 'MY_ACTION_START' }, callback);
56 |
57 | myActionCreator()
58 | .should.not.dispatch.actions({ type: 'MY_ACTION_START' }, callback);
59 |
60 | assert.isNotDispatching(
61 | myActionCreator(),
62 | { type: 'MY_ACTION_START' },
63 | callback
64 | );
65 | ```
66 |
67 | ### .with.state or assert.isDispatchingWithState and assert.isNotDispatchingWithState
68 |
69 | > `expect(action).with.state(state).to.dispatch.actions(expectedActions, callback)`
70 | > `expect(action).with.state(state).not.to.dispatch.actions(expectedActions, callback)`
71 | > `expect(action).with.state(state).to.not.dispatch.actions(expectedActions, callback)`
72 |
73 | > `action.should.with.state(state).dispatch.actions(expectedActions, callback)`
74 | > `action.should.with.state(state).not.dispatch.actions(expectedActions, callback)`
75 |
76 | > `assert.isDispatchingWithState(action, expectedActions, state, callback)`
77 | > `assert.isNotDispatchingWithState(action, expectedActions, state, callback)`
78 |
79 | Asserts that store initialised with `state` before `action` is dispatched.
80 | ```js
81 | expect(myActionCreator())
82 | .with.state({ property: 'value' })
83 | .to.dispatch.actions([{ type: 'MY_ACTION_START' }, finishActionCreator()], callback);
84 |
85 | myActionCreator()
86 | .should.with.({ property: 'value' })
87 | .dispatch.actions([{ type: 'MY_ACTION_START' }, finishActionCreator()], callback);
88 |
89 | assert.isDispatchingWithState(
90 | myActionCreator(),
91 | [{ type: 'MY_ACTION_START' }, finishActionCreator()],
92 | { property: 'value' }
93 | callback
94 | );
95 |
96 | assert.isNotDispatchingWithState(
97 | myActionCreator(),
98 | [{ type: 'MY_ACTION_START' }, finishActionCreator()],
99 | { property: 'value' }
100 | callback
101 | );
102 | ```
--------------------------------------------------------------------------------
/documentation/expect.md:
--------------------------------------------------------------------------------
1 | # [expect](https://github.com/mjackson/expect)
2 |
3 | ## Registration
4 |
5 | ```js
6 | // using ES6 modules
7 | import { registerAssertions } from 'redux-actions-assertions/expect';
8 |
9 | // using CommonJS modules
10 | var registerAssertions = require('redux-actions-assertions/expect').registerAssertions;
11 |
12 | // registration
13 | registerAssertions();
14 | ```
15 |
16 | ## Usage
17 |
18 | ### .toDispatchActions
19 |
20 | > `expect(action).toDispatchActions(expectedActions, callback)`
21 |
22 | Asserts that when given `action` is dispatched it will dispatch `expectedActions`. `action` can be plain object (action) or function (action creator). `expectedActions` can be can be plain object (action) or function (action creator) or array of objects/functions.
23 |
24 | ```js
25 | expect(myActionCreator())
26 | .toDispatchActions({ type: 'MY_ACTION_START' }, callback);
27 | ```
28 |
29 | ### .toNotDispatchActions
30 |
31 | > `expect(action).toNotDispatchActions(expectedActions, callback)`
32 |
33 | Asserts that when given `action` is dispatched it will not dispatch `expectedActions`. `action` can be plain object (action) or function (action creator). `expectedActions` can be can be plain object (action) or function (action creator) or array of objects/functions.
34 |
35 | ```js
36 | expect(myActionCreator())
37 | .toNotDispatchActions({ type: 'MY_ACTION_START' }, callback);
38 | ```
39 |
40 | ### .withState
41 |
42 | > `expect(action).withState(state).toDispatchActions(expectedActions, callback)`
43 |
44 | Asserts that store initialised with `state` before `action` is dispatched.
45 |
46 | ```js
47 | expect(myActionCreator())
48 | .withState({property: 'value'})
49 | .toDispatchActions([{ type: 'MY_ACTION_START' }, finishActionCreator()], callback);
50 | ```
--------------------------------------------------------------------------------
/documentation/expectjs.md:
--------------------------------------------------------------------------------
1 | # [expect.js](https://github.com/Automattic/expect.js)
2 |
3 | ## Registration
4 |
5 | ```js
6 | // using ES6 modules
7 | import { registerAssertions } from 'redux-actions-assertions/expectjs';
8 |
9 | // using CommonJS modules
10 | var registerAssertions = require('redux-actions-assertions/expectjs').registerAssertions;
11 |
12 | // registration
13 | registerAssertions();
14 | ```
15 |
16 | ## Usage
17 |
18 | ### .dispatchActions
19 |
20 | > `expect(action).to.dispatchActions(expectedActions, callback)`
21 |
22 | Asserts that when given `action` is dispatched it will dispatch `expectedActions`. `action` can be plain object (action) or function (action creator). `expectedActions` can be can be plain object (action) or function (action creator) or array of objects/functions.
23 |
24 | ```js
25 | expect(myActionCreator())
26 | .to.dispatchActions({ type: 'MY_ACTION_START' }, callback);
27 | ```
28 |
29 | ### .not.dispatchActions
30 |
31 | > `expect(action).not.to.dispatchActions(expectedActions, callback)`
32 | > `expect(action).to.not.dispatchActions(expectedActions, callback)`
33 |
34 | Asserts that when given `action` is dispatched it will not dispatch `expectedActions`. `action` can be plain object (action) or function (action creator). `expectedActions` can be can be plain object (action) or function (action creator) or array of objects/functions.
35 |
36 | ```js
37 | expect(myActionCreator())
38 | .not.to.dispatchActions({ type: 'MY_ACTION_START' }, callback);
39 |
40 | expect(myActionCreator())
41 | .to.not.dispatchActions({ type: 'MY_ACTION_START' }, callback);
42 | ```
43 |
44 | ### .withState
45 |
46 | > `expect(action).withState(state).to.dispatchActions(expectedActions, callback)`
47 |
48 | Asserts that store initialised with `state` before `action` is dispatched.
49 |
50 | ```js
51 | expect(myActionCreator())
52 | .withState({ property: 'value' })
53 | .to.dispatchActions([{ type: 'MY_ACTION_START' }, finishActionCreator()], callback);
54 | ```
55 |
--------------------------------------------------------------------------------
/documentation/installation.md:
--------------------------------------------------------------------------------
1 | # Installation
2 |
3 | Using [npm](https://www.npmjs.org/):
4 |
5 | $ npm install --save-dev redux-actions-assertions
6 |
7 | ## Redux middlewares registration
8 |
9 | ```js
10 | // using ES6 modules
11 | import { registerMiddlewares } from 'redux-actions-assertions';
12 |
13 | // using CommonJS modules
14 | var registerMiddlewares = require('redux-actions-assertions').registerMiddlewares;
15 |
16 | // registration
17 | registerMiddlewares([
18 | /* Here you need to list your middlewares */
19 | ]);
20 | ```
21 |
22 | ## Default initial store state registration
23 |
24 | **By using state object or function:**
25 | ```js
26 | // using ES6 modules
27 | import { registerInitialStoreState } from 'redux-actions-assertions';
28 |
29 | // using CommonJS modules
30 | var registerInitialStoreState = require('redux-actions-assertions').registerInitialStoreState;
31 |
32 | // registration
33 | registerInitialStoreState(/* default initial state object or function */);
34 | ```
35 | **By using your root reducer:**
36 | ```js
37 | // using ES6 modules
38 | import { buildInitialStoreState, registerInitialStoreState } from 'redux-actions-assertions';
39 |
40 | // using CommonJS modules
41 | var reduxActionsAssertions = require('redux-actions-assertions');
42 | var registerInitialStoreState = reduxActionsAssertions.registerInitialStoreState;
43 |
44 | // registration
45 | registerInitialStoreState(buildInitialStoreState(/* root reducer function */));
46 | ```
47 |
--------------------------------------------------------------------------------
/documentation/jasmine.md:
--------------------------------------------------------------------------------
1 | # [jasmine](https://github.com/jasmine/jasmine)
2 |
3 | ## Registration
4 |
5 | ```js
6 | // using ES6 modules
7 | import { registerAssertions } from 'redux-actions-assertions/jasmine';
8 |
9 | // using CommonJS modules
10 | var registerAssertions = require('redux-actions-assertions/jasmine').registerAssertions;
11 |
12 | // registration
13 | beforeEach(registerAssertions);
14 | ```
15 |
16 | ## Usage
17 |
18 | ### .toDispatchActions
19 |
20 | > `expect(action).toDispatchActions(expectedActions, done)`
21 |
22 | Asserts that when given `action` is dispatched it will dispatch `expectedActions`. `action` can be plain object (action) or function (action creator). `expectedActions` can be can be plain object (action) or function (action creator) or array of objects/functions.
23 |
24 | ```js
25 | expect(myActionCreator())
26 | .toDispatchActions({ type: 'MY_ACTION_START' }, done);
27 | ```
28 |
29 | ### .not.toDispatchActions
30 |
31 | > `expect(action).not.toDispatchActions(expectedActions, done)`
32 |
33 | Asserts that when given `action` is dispatched it will not dispatch `expectedActions`. `action` can be plain object (action) or function (action creator). `expectedActions` can be can be plain object (action) or function (action creator) or array of objects/functions.
34 |
35 | ```js
36 | expect(myActionCreator())
37 | .not.toDispatchActions({ type: 'MY_ACTION_START' }, done);
38 | ```
39 |
40 | ### .toDispatchActionsWithState
41 |
42 | > `expect(action).toDispatchActionsWithState(state, expectedActions, done)`
43 |
44 | Asserts that store initialised with `state` before `action` is dispatched.
45 |
46 | ```js
47 | const state = {property: 'value'};
48 | const expectedActions = [{ type: 'MY_ACTION_START' }, finishActionCreator()];
49 | expect(myActionCreator())
50 | .toDispatchActionsWithState(state, expectedActions, done);
51 | ```
52 | You can also use it with `.not`:
53 |
54 | ```js
55 | expect(myActionCreator())
56 | .not.toDispatchActionsWithState(state, expectedActions, done);
57 | ```
58 |
--------------------------------------------------------------------------------
/documentation/javascript.md:
--------------------------------------------------------------------------------
1 | # javascript
2 |
3 | ## Registration
4 |
5 | ```js
6 | // using ES6 modules
7 | import { assertions } from 'redux-actions-assertions';
8 |
9 | // using CommonJS modules
10 | var assertions = require('redux-actions-assertions').assertions;
11 |
12 | // in test
13 | assertions.toDispatchActions(/**/)
14 | assertions.toNotDispatchActions(/**/)
15 | assertions.toDispatchActionsWithState(/**/);
16 | assertions.toNotDispatchActionsWithState(/**/);
17 | ```
18 |
19 | For plain javascript assertions you don't need to register anything. Just import assertions in your tests:
20 |
21 | ## Usage
22 |
23 | ### toDispatchActions
24 | > `toDispatchActions(action, expectedActions, callback)`
25 |
26 | Asserts that when given `action` is dispatched it will dispatch `expectedActions`. `action` can be plain object (action) or function (action creator). `expectedActions` can be can be plain object (action) or function (action creator) or array of objects/functions.
27 |
28 | ```js
29 | toDispatchActions(testActionCreator(), [{ type: 'MY_ACTION_START' }], callback);
30 | ```
31 |
32 | ### toNotDispatchActions
33 | > `toNotDispatchActions(action, expectedActions, callback)`
34 |
35 | Asserts that when given `action` is dispatched it will not dispatch `expectedActions`. `action` can be plain object (action) or function (action creator). `expectedActions` can be can be plain object (action) or function (action creator) or array of objects/functions.
36 |
37 | ```js
38 | toNotDispatchActions(testActionCreator(), [{ type: 'MY_ACTION_START' }], callback);
39 | ```
40 |
41 | ### toDispatchActionsWithState
42 |
43 | > `toDispatchActionsWithState(initialState, action, expectedActions, callback)`
44 |
45 | Same as `toDispatchActions` + asserts that store initialised with `state` before `action` is dispatched.
46 |
47 | ```js
48 | toDispatchActions({property: 'value'}, testActionCreator(), [{ type: 'MY_ACTION_START' }], callback);
49 | ```
50 |
51 | ### toNotDispatchActionsWithState
52 |
53 | > `toNotDispatchActionsWithState(initialState, action, expectedActions, callback)`
54 |
55 | Same as `toNotDispatchActions` + asserts that store initialised with `state` before `action` is dispatched.
56 |
57 | ```js
58 | toNotDispatchActions({property: 'value'}, testActionCreator(), [{ type: 'MY_ACTION_START' }], callback);
59 | ```
60 |
--------------------------------------------------------------------------------
/documentation/jest.md:
--------------------------------------------------------------------------------
1 | # [jest](https://github.com/facebook/jest)
2 |
3 | ## Registration
4 |
5 | ```js
6 | // add these two lines in your setupTestFrameworkScriptFile:
7 | // http://facebook.github.io/jest/docs/configuration.html#setuptestframeworkscriptfile-string
8 | import { registerAssertions } from 'redux-actions-assertions/jest';
9 |
10 | beforeEach(registerAssertions);
11 | ```
12 |
13 | ## Usage
14 |
15 | ### .toDispatchActions
16 |
17 | > `expect(action).toDispatchActions(expectedActions, done)`
18 |
19 | Asserts that when given `action` is dispatched it will dispatch `expectedActions`. `action` can be plain object (action) or function (action creator). `expectedActions` can be can be plain object (action) or function (action creator) or array of objects/functions.
20 |
21 | ```js
22 | expect(myActionCreator())
23 | .toDispatchActions({ type: 'MY_ACTION_START' }, done);
24 | ```
25 |
26 | ### .toNotDispatchActions
27 |
28 | > `expect(action).toNotDispatchActions(expectedActions, done)`
29 |
30 | Asserts that when given `action` is dispatched it will not dispatch `expectedActions`. `action` can be plain object (action) or function (action creator). `expectedActions` can be can be plain object (action) or function (action creator) or array of objects/functions.
31 |
32 | ```js
33 | expect(myActionCreator())
34 | .toNotDispatchActions({ type: 'MY_ACTION_START' }, done);
35 | ```
36 |
37 | ### .toDispatchActionsWithState
38 |
39 | > `expect(action).toDispatchActionsWithState(state, expectedActions, done)`
40 |
41 | Asserts that store initialised with `state` before `action` is dispatched.
42 |
43 | ```js
44 | const state = {property: 'value'};
45 | const expectedActions = [{ type: 'MY_ACTION_START' }, finishActionCreator()];
46 | expect(myActionCreator())
47 | .toDispatchActionsWithState(state, expectedActions, done);
48 | ```
49 | You can also use its variant `.toNotDispatchActionsWithState`:
50 |
51 | ```js
52 | expect(myActionCreator())
53 | .toNotDispatchActionsWithState(state, expectedActions, done);
54 | ```
55 |
--------------------------------------------------------------------------------
/documentation/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "redux-actions-assertions-docs",
3 | "version": "0.0.1",
4 | "description": "Docs for redux-actions-assertions",
5 | "main": "index.js",
6 | "scripts": {
7 | "build": "gitbook install && gitbook build ./ ../docs"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "gitbook-plugin-ga": "^1.0.1"
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/documentation/should.md:
--------------------------------------------------------------------------------
1 | # [should](https://github.com/shouldjs/should.js)
2 |
3 | ## Registration
4 |
5 | ```js
6 | // using ES6 modules
7 | import { registerAssertions } from 'redux-actions-assertions/should';
8 |
9 | // using CommonJS modules
10 | var registerAssertions = require('redux-actions-assertions/should').registerAssertions;
11 |
12 | // registration
13 | registerAssertions();
14 | ```
15 |
16 | ## Usage
17 |
18 | ### .dispatchActions
19 |
20 | > `should(action).dispatchActions(expectedActions, callback)`
21 | > `action.should.dispatchActions(expectedActions, callback)`
22 |
23 | Asserts that when given `action` is dispatched it will dispatch `expectedActions`. `action` can be plain object (action) or function (action creator). `expectedActions` can be can be plain object (action) or function (action creator) or array of objects/functions.
24 |
25 | ```js
26 | should(myActionCreator())
27 | .dispatchActions({ type: 'MY_ACTION_START' }, callback);
28 |
29 | myActionCreator().should
30 | .dispatchActions({ type: 'MY_ACTION_START' }, callback);
31 | ```
32 |
33 |
34 | ### .notDispatchActions
35 |
36 | > `should(action).notDispatchActions(expectedActions, callback)`
37 | > `action.should.notDispatchActions(expectedActions, callback)`
38 |
39 | Asserts that when given `action` is dispatched it will not dispatch `expectedActions`. `action` can be plain object (action) or function (action creator). `expectedActions` can be can be plain object (action) or function (action creator) or array of objects/functions.
40 |
41 | ```js
42 | should(myActionCreator())
43 | .notDispatchActions({ type: 'MY_ACTION_START' }, callback);
44 |
45 | myActionCreator().should
46 | .notDispatchActions({ type: 'MY_ACTION_START' }, callback);
47 | ```
48 |
49 | ### .withState or with.state
50 |
51 | > `should(action).withState(state).dispatchActions(expectedActions, callback)`
52 | > `should(action).with.state(state).dispatchActions(expectedActions, callback)`
53 |
54 | > `action.should.withState(state).dispatchActions(expectedActions, callback)`
55 | > `action.should.with.state(state).dispatchActions(expectedActions, callback)`
56 |
57 | Asserts that store initialised with `state` before `action` is dispatched.
58 |
59 | ```js
60 | should(myActionCreator())
61 | .withState({ property: 'value' })
62 | .dispatchActions({ type: 'MY_ACTION_START' }, callback);
63 |
64 | should(myActionCreator())
65 | .with.state({ property: 'value' })
66 | .dispatchActions({ type: 'MY_ACTION_START' }, callback);
67 |
68 | myActionCreator().should
69 | .withState({ property: 'value' })
70 | .dispatchActions({ type: 'MY_ACTION_START' }, callback);
71 |
72 | myActionCreator().should
73 | .with.state({ property: 'value' })
74 | .dispatchActions({ type: 'MY_ACTION_START' }, callback);
75 | ```
--------------------------------------------------------------------------------
/documentation/tape.md:
--------------------------------------------------------------------------------
1 | # [tape](https://github.com/substack/tape)
2 |
3 | ## Usage
4 |
5 | ```js
6 | // using ES6 modules
7 | import test from 'tape';
8 | import { assertions } from 'redux-actions-assertions';
9 |
10 | // using CommonJS modules
11 | var test = require('tape');
12 | var assertions = require('redux-actions-assertions').assertions;
13 | ```
14 |
15 | Usage is the same as the [plain JavaScript assertions](https://redux-things.github.io/redux-actions-assertions/javascript.html), you just need to set up the correct `pass` and `fail` callbacks. Also, be sure to call `end` in a `Promise.then`, or `plan` with the number of assertions you're making in the test (see below).
16 |
17 | ### toDispatchActions
18 | > `toDispatchActions(action, expectedActions, done, fail)`
19 |
20 | Asserts that when given `action` is dispatched it will dispatch `expectedActions`. `action` can be plain object (action) or function (action creator). `expectedActions` can be can be plain object (action) or function (action creator) or array of objects/functions.
21 |
22 | ```js
23 | // Using `t.plan`
24 | test('Thunk: editTag', (t) => {
25 | t.plan(1)
26 | toDispatchActions(testActionCreator(), [{ type: 'MY_ACTION_START' }], t.pass, t.fail);
27 | });
28 |
29 | // Using `t.end`
30 | test('Thunk: editTag', (t) => {
31 | toDispatchActions(testActionCreator(), [{ type: 'MY_ACTION_START' }], t.pass, t.fail)
32 | .then(t.end);
33 | });
34 | ```
35 |
36 | ### toNotDispatchActions
37 | > `toNotDispatchActions(action, expectedActions, done, fail)`
38 |
39 | Asserts that when given `action` is dispatched it will not dispatch `expectedActions`. `action` can be plain object (action) or function (action creator). `expectedActions` can be can be plain object (action) or function (action creator) or array of objects/functions.
40 |
41 | ```js
42 | test('Thunk: editTag', (t) => {
43 | t.plan(1);
44 | toNotDispatchActions(testActionCreator(), [{ type: 'MY_ACTION_START' }], t.pass, t.fail);
45 | });
46 | ```
47 |
48 | ### toDispatchActionsWithState
49 |
50 | > `toDispatchActionsWithState(initialState, action, expectedActions, done, fail)`
51 |
52 | Same as `toDispatchActions` + asserts that store initialised with `state` before `action` is dispatched.
53 |
54 | ```js
55 | test('Thunk: editTag', (t) => {
56 | t.plan(1);
57 | toDispatchActions({property: 'value'}, testActionCreator(), [{ type: 'MY_ACTION_START' }], t.pass, t.fail);
58 | });
59 | ```
60 |
61 | ### toNotDispatchActionsWithState
62 |
63 | > `toNotDispatchActionsWithState(initialState, action, expectedActions, done, fail)`
64 |
65 | Same as `toNotDispatchActions` + asserts that store initialised with `state` before `action` is dispatched.
66 |
67 | ```js
68 | test('Thunk: editTag', (t) => {
69 | t.plan(1);
70 | toNotDispatchActions({property: 'value'}, testActionCreator(), [{ type: 'MY_ACTION_START' }], t.pass, t.fail);
71 | });
72 | ```
73 |
--------------------------------------------------------------------------------
/documentation/what_it_does.md:
--------------------------------------------------------------------------------
1 | # What it does
2 |
3 | ## Allows to avoid retesting nested action creators
4 | It allows to test only actions that need to be tested.
5 |
6 | **Example:**
7 | We have two actions (A, B). Each one makes async http requests.
8 | Action A makes a request and if the result is successful it triggers Action B.
9 | Action B is also used as an independent action.
10 | Action B can be tested separately.
11 | Therefore, we don't need to test it again in Action A.
12 |
13 | Actions:
14 | ```javascript
15 | function actionA() {
16 | return dispatch => {
17 | dispatch(actionAStart());
18 | return api.getA().then(response => {
19 | dispatch(actionAFinish(response));
20 | dispatch(actionB());
21 | }).catch(err => {
22 | dispatch(actionAFailure(err));
23 | });
24 | };
25 | }
26 |
27 | function actionB() {
28 | return dispatch => {
29 | dispatch(actionBStart());
30 | return api.getB().then(response => {
31 | dispatch(actionBFinish(response));
32 | }).catch(err => {
33 | dispatch(actionBFailure(err));
34 | });
35 | };
36 | }
37 | ```
38 |
39 | Without:
40 | ```javascript
41 | const expectedActions = [
42 | { type: action_a_start },
43 | { type: action_a_success },
44 | { type: action_b_start }, // retesting of action B
45 | { type: action_b_success } // retesting of action B];
46 | const store = mockStore({ todos: [] });
47 | store.dispatch(actionA()).then(() => {
48 | expect(store.getActions()).toEqual(expectedActions);
49 | }).then(done).catch(done);
50 | ```
51 |
52 | With:
53 | ```javascript
54 | expect(actionA()).withState({ todos: [] }).toDispatch([
55 | { type: action_a_start },
56 | { type: action_a_success },
57 | actionB() // just executing tested action
58 | ], done);
59 | ```
60 |
61 | ## Reduces repetitive code of test methods
62 | It reduces boilerplate of test methods and makes testing fluent.
63 |
64 | Without:
65 | ```javascript
66 | const store = mockStore(/* initial state */);
67 | const expectedActions = [
68 | { type: types.FETCH_TODOS_REQUEST },
69 | /* All expected triggered action objects */
70 | ];
71 | store.dispatch(fetchData()).then(() => {
72 | const actions = store.getActions();
73 | expect(actions).toEqual(expectedActions);
74 | }).then(done).catch(done);
75 | ```
76 |
77 | With:
78 | ```javascript
79 | const expectedActions = [
80 | /*All expected triggered action objects or action creator functions*/
81 | ];
82 | expect(fetchData()).toDispatchActions(expectedActions, done);
83 | ```
84 |
85 | With using customised store state:
86 | ```javascript
87 | expect(fetchData()).withState({/*custom state*/}).toDispatchActions(expectedActions, done);
88 | ```
89 |
90 | ## Simplifies initial setup
91 | It provides singe-time global configuration for middlewares and initial store state.
92 |
93 | Without:
94 | ```javascript
95 | const middlewares = [thunk];
96 | const mockStore = configureStore(middlewares);
97 | const store = mockStore({ /*initial store object*});
98 | ```
99 | With:
100 | ```javascript
101 | registerMiddlewares([ thunk ]);
102 | // to set custom initial state
103 | registerInitialStoreState(/*object of function*/);
104 | // to generate initial state of your application
105 | registerInitialStoreState(buildInitialStoreState(/*your root reducer*/));
106 | ```
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "redux-actions-assertions-src",
3 | "description": "Assertions for redux actions testing",
4 | "scripts": {
5 | "lint": "eslint src test",
6 | "test:index": "mocha --compilers js:babel-register --reporter spec test/*.js",
7 | "test:chai": "mocha --compilers js:babel-register --reporter spec test/chai/*.js",
8 | "test:expect": "mocha --compilers js:babel-register --reporter spec test/expect/*.js",
9 | "test:expectjs": "mocha --compilers js:babel-register --reporter spec test/expectjs/*.js",
10 | "test:jasmine": "jasmine JASMINE_CONFIG_PATH=test/jasmine/jasmine.json",
11 | "test:jest": "jest --config test/jest/jest.json",
12 | "test:should": "mocha --compilers js:babel-register --reporter spec test/should/*.js",
13 | "test:tape": "tape --require babel-register test/tape/*.js",
14 | "test": "npm run test:index && npm run test:chai && npm run test:expect && npm run test:expectjs && npm run test:jasmine && npm run test:jest && npm run test:should && npm run test:tape",
15 | "copy-resources": "cp README.md ./build && cp LICENSE ./build",
16 | "build": "rimraf build && babel src --out-dir build --copy-files ",
17 | "prepublish": "npm run build && npm run copy-resources",
18 | "docs:build": "cd documentation && npm run build"
19 | },
20 | "repository": {
21 | "type": "git",
22 | "url": "git+https://github.com/dmitry-zaets/redux-actions-assertions.git"
23 | },
24 | "authors": [
25 | "Dmitry Zaets",
26 | "Yann Torres"
27 | ],
28 | "license": "MIT",
29 | "bugs": {
30 | "url": "https://github.com/redux-things/redux-actions-assertions/issues"
31 | },
32 | "homepage": "https://github.com/redux-things/redux-actions-assertions#readme",
33 | "devDependencies": {
34 | "babel-cli": "^6.9.0",
35 | "babel-preset-es2015": "^6.9.0",
36 | "babel-register": "^6.9.0",
37 | "chai": "^3.5.0",
38 | "eslint": "^2.10.2",
39 | "eslint-config-airbnb-base": "^3.0.1",
40 | "eslint-plugin-babel": "^3.2.0",
41 | "eslint-plugin-import": "^1.8.0",
42 | "expect": "^1.20.1",
43 | "expect.js": "^0.3.1",
44 | "jasmine": "^2.5.2",
45 | "jest": "^18.1.0",
46 | "mocha": "^2.4.5",
47 | "redux-thunk": "^2.1.0",
48 | "rimraf": "^2.5.2",
49 | "should": "^8.3.2",
50 | "tape": "^4.6.0"
51 | },
52 | "dependencies": {
53 | "redux-actions-assertions-js": "^1.1.0"
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/actionWithInitialState.js:
--------------------------------------------------------------------------------
1 | function ActionWithInitialState(action, state) {
2 | this.action = action;
3 | this.state = state;
4 | }
5 | export default ActionWithInitialState;
6 |
--------------------------------------------------------------------------------
/src/chai.js:
--------------------------------------------------------------------------------
1 | import chai from 'chai';
2 | import { assertions } from 'redux-actions-assertions-js';
3 |
4 | function registerAssertions() {
5 | chai.use((_chai, utils) => {
6 | function stateMethod(stateValue) {
7 | utils.flag(this, 'state', stateValue);
8 | }
9 |
10 | function dispatchProperty() {
11 | utils.flag(this, 'dispatch', true);
12 | }
13 |
14 | function dispatchActionsMethod(expectedActions, done) {
15 | if (!utils.flag(this, 'dispatch')) {
16 | throw new Error('"actions" should be used after "dispatch"');
17 | }
18 |
19 | const state = utils.flag(this, 'state');
20 | if (state) {
21 | if (utils.flag(this, 'negate')) {
22 | return assertions.toNotDispatchActionsWithState(state, this._obj, expectedActions, done);
23 | }
24 | return assertions.toDispatchActionsWithState(state, this._obj, expectedActions, done);
25 | }
26 | if (utils.flag(this, 'negate')) {
27 | return assertions.toNotDispatchActions(this._obj, expectedActions, done);
28 | }
29 | return assertions.toDispatchActions(this._obj, expectedActions, done);
30 | }
31 |
32 | function isDispatching(actualAction, expectedActions, done) {
33 | new _chai.Assertion(actualAction)
34 | .to.dispatch.actions(expectedActions, done);
35 | }
36 |
37 | function isDispatchingWithState(actualAction, expectedActions, state, done) {
38 | new _chai.Assertion(actualAction)
39 | .with.state(state)
40 | .to.dispatch.actions(expectedActions, done);
41 | }
42 |
43 | function isNotDispatching(actualAction, expectedActions, done) {
44 | new _chai.Assertion(actualAction)
45 | .to.not.dispatch.actions(expectedActions, done);
46 | }
47 |
48 | function isNotDispatchingWithState(actualAction, expectedActions, state, done) {
49 | new _chai.Assertion(actualAction)
50 | .with.state(state)
51 | .to.not.dispatch.actions(expectedActions, done);
52 | }
53 |
54 | _chai.Assertion.addChainableMethod('state', stateMethod);
55 | _chai.Assertion.addProperty('dispatch', dispatchProperty);
56 | _chai.Assertion.addMethod('actions', dispatchActionsMethod);
57 | _chai.assert.isDispatching = isDispatching;
58 | _chai.assert.isDispatchingWithState = isDispatchingWithState;
59 | _chai.assert.isNotDispatching = isNotDispatching;
60 | _chai.assert.isNotDispatchingWithState = isNotDispatchingWithState;
61 | });
62 | }
63 |
64 | export {
65 | registerAssertions
66 | };
67 |
--------------------------------------------------------------------------------
/src/expect.js:
--------------------------------------------------------------------------------
1 | import expect from 'expect';
2 | import { assertions } from 'redux-actions-assertions-js';
3 |
4 | function withState(state) {
5 | this.state = state;
6 | return this;
7 | }
8 |
9 | function toDispatchActions(expectedActions, done) {
10 | if (this.state) {
11 | return assertions.toDispatchActionsWithState(this.state, this.actual, expectedActions, done);
12 | }
13 | return assertions.toDispatchActions(this.actual, expectedActions, done);
14 | }
15 |
16 | function toNotDispatchActions(expectedActions, done) {
17 | if (this.state) {
18 | return assertions.toNotDispatchActionsWithState(this.state, this.actual, expectedActions, done);
19 | }
20 | return assertions.toNotDispatchActions(this.actual, expectedActions, done);
21 | }
22 |
23 | function registerAssertions() {
24 | expect.extend({
25 | toDispatchActions,
26 | toNotDispatchActions,
27 | withState
28 | });
29 | }
30 |
31 | export {
32 | registerAssertions
33 | };
34 |
--------------------------------------------------------------------------------
/src/expectjs.js:
--------------------------------------------------------------------------------
1 | import expect from 'expect.js';
2 | import { assertions } from 'redux-actions-assertions-js';
3 | import ActionWithInitialState from './actionWithInitialState';
4 |
5 | function withState(state) {
6 | return expect(new ActionWithInitialState(this.obj, state));
7 | }
8 |
9 | function dispatchActions(expectedActions, done) {
10 | if (this.obj instanceof ActionWithInitialState) {
11 | const action = this.obj.action;
12 | const state = this.obj.state;
13 | if (this.flags.not) {
14 | assertions.toNotDispatchActionsWithState(state, action, expectedActions, done);
15 | } else {
16 | assertions.toDispatchActionsWithState(state, action, expectedActions, done);
17 | }
18 | } else {
19 | if (this.flags.not) {
20 | assertions.toNotDispatchActions(this.obj, expectedActions, done);
21 | } else {
22 | assertions.toDispatchActions(this.obj, expectedActions, done);
23 | }
24 | }
25 | }
26 |
27 | function registerAssertions() {
28 | expect.Assertion.prototype.withState = withState;
29 | expect.Assertion.prototype.dispatchActions = dispatchActions;
30 | }
31 |
32 | export {
33 | registerAssertions
34 | };
35 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | export { registerMiddlewares,
2 | registerInitialStoreState,
3 | buildInitialStoreState,
4 | assertions
5 | } from 'redux-actions-assertions-js';
6 |
--------------------------------------------------------------------------------
/src/jasmine.js:
--------------------------------------------------------------------------------
1 | /* eslint-env jasmine */
2 | import { assertions } from 'redux-actions-assertions-js';
3 |
4 | function toDispatchActions() {
5 | return {
6 | compare(action, expectedActions, done) {
7 | assertions.toDispatchActions(action, expectedActions, done, done.fail);
8 | return { pass: true };
9 | },
10 | negativeCompare(action, expectedActions, done) {
11 | assertions.toNotDispatchActions(action, expectedActions, done, done.fail);
12 | return { pass: true };
13 | }
14 | };
15 | }
16 |
17 | function toNotDispatchActions() {
18 | return {
19 | compare(action, expectedActions, done) {
20 | assertions.toNotDispatchActions(action, expectedActions, done, done.fail);
21 | return { pass: true };
22 | }
23 | };
24 | }
25 |
26 | function toDispatchActionsWithState() {
27 | return {
28 | compare(action, state, expectedActions, done) {
29 | assertions.toDispatchActionsWithState(state, action, expectedActions, done, done.fail);
30 | return { pass: true };
31 | },
32 | negativeCompare(action, state, expectedActions, done) {
33 | assertions.toNotDispatchActionsWithState(state, action, expectedActions, done, done.fail);
34 | return { pass: true };
35 | }
36 | };
37 | }
38 |
39 | function toNotDispatchActionsWithState() {
40 | return {
41 | compare(action, state, expectedActions, done) {
42 | assertions.toNotDispatchActionsWithState(state, action, expectedActions, done, done.fail);
43 | return { pass: true };
44 | }
45 | };
46 | }
47 |
48 | const matchers = {
49 | toDispatchActions,
50 | toNotDispatchActions,
51 | toDispatchActionsWithState,
52 | toNotDispatchActionsWithState
53 | };
54 |
55 | function registerAssertions() {
56 | jasmine.addMatchers(matchers);
57 | }
58 |
59 | export {
60 | registerAssertions
61 | };
62 |
--------------------------------------------------------------------------------
/src/jest.js:
--------------------------------------------------------------------------------
1 | import { registerAssertions } from './jasmine';
2 |
3 | export { registerAssertions };
4 |
--------------------------------------------------------------------------------
/src/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "redux-actions-assertions",
3 | "version": "1.3.0",
4 | "description": "Assertions for redux actions testing",
5 | "scripts": {
6 | },
7 | "repository": {
8 | "type": "git",
9 | "url": "git+https://github.com/redux-things/redux-actions-assertions/t"
10 | },
11 | "authors": [
12 | "Dmitry Zaets",
13 | "Yann Torres"
14 | ],
15 | "license": "MIT",
16 | "bugs": {
17 | "url": "https://github.com/redux-things/redux-actions-assertions/issues"
18 | },
19 | "homepage": "https://github.com/redux-things/redux-actions-assertions#readme",
20 | "keywords": [
21 | "redux",
22 | "actions",
23 | "testing",
24 | "test",
25 | "assertions",
26 | "asserts"
27 | ],
28 | "dependencies": {
29 | "redux-actions-assertions-js": "^1.1.0"
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/should.js:
--------------------------------------------------------------------------------
1 | import should from 'should';
2 | import { assertions } from 'redux-actions-assertions-js';
3 | import ActionWithInitialState from './actionWithInitialState';
4 |
5 | function withState(state) {
6 | this.obj = new ActionWithInitialState(this.obj, state);
7 | }
8 |
9 | function dispatchActionsFunction(assert, assertWithState, expectedActions, done) {
10 | if (this.obj instanceof ActionWithInitialState) {
11 | const action = this.obj.action;
12 | const state = this.obj.state;
13 | assertWithState(state, action, expectedActions, done);
14 | } else {
15 | assert(this.obj, expectedActions, done);
16 | }
17 | }
18 |
19 | function dispatchActions(expectedActions, done) {
20 | dispatchActionsFunction.call(
21 | this,
22 | assertions.toDispatchActions,
23 | assertions.toDispatchActionsWithState,
24 | expectedActions,
25 | done
26 | );
27 | }
28 |
29 | function notDispatchActions(expectedActions, done) {
30 | dispatchActionsFunction.call(
31 | this,
32 | assertions.toNotDispatchActions,
33 | assertions.toNotDispatchActionsWithState,
34 | expectedActions,
35 | done
36 | );
37 | }
38 |
39 | function registerAssertions() {
40 | should.Assertion.add('withState', withState);
41 | should.Assertion.alias('withState', 'state');
42 | should.Assertion.add('dispatchActions', dispatchActions);
43 | should.Assertion.add('notDispatchActions', notDispatchActions);
44 | }
45 |
46 | export {
47 | registerAssertions
48 | };
49 |
--------------------------------------------------------------------------------
/test/chai/index.js:
--------------------------------------------------------------------------------
1 | import { should, expect, assert } from 'chai';
2 | import thunk from 'redux-thunk';
3 | import { registerMiddlewares } from '../../src';
4 | import { registerAssertions } from '../../src/chai';
5 | import actions from '../testingData/actions';
6 |
7 | should();
8 | registerMiddlewares([thunk]);
9 | registerAssertions();
10 |
11 | describe('chai', () => {
12 | describe('expect', () => {
13 | describe('.with.state', () => {
14 | it('should accept object', (done) => {
15 | expect(actions.actionCreatorWithGetState())
16 | .with.state({ property: 'value' })
17 | .to.dispatch.actions(actions.actionWithGetState({ property: 'value' }), done);
18 | });
19 |
20 | it('should accept function', (done) => {
21 | expect(actions.actionCreatorWithGetState())
22 | .with.state(() => { return { property: 'value' }; })
23 | .to.dispatch.actions(actions.actionWithGetState({ property: 'value' }), done);
24 | });
25 | });
26 |
27 | describe('.dispatch.actions', () => {
28 | it('should accept single action', (done) => {
29 | expect(actions.start())
30 | .to.dispatch.actions(actions.start(), done);
31 | });
32 |
33 | it('should accept array with one action', (done) => {
34 | expect(actions.start())
35 | .to.dispatch.actions([actions.start()], done);
36 | });
37 |
38 | it('should accept array with multiple actions', (done) => {
39 | expect(actions.asyncActionCreator())
40 | .to.dispatch.actions(actions.expectedActions, done);
41 | });
42 |
43 | it('should accept array with nested async action creators', (done) => {
44 | expect(actions.parentAsyncActionCreator())
45 | .to.dispatch.actions(actions.expectedParentActions, done);
46 | });
47 | });
48 |
49 | describe('.not.dispatch.actions', () => {
50 | it('should accept single action', (done) => {
51 | expect(actions.start())
52 | .to.not.dispatch.actions(actions.anotherStart(), done);
53 | });
54 |
55 | it('should accept array with one action', (done) => {
56 | expect(actions.start())
57 | .to.not.dispatch.actions([actions.anotherStart()], done);
58 | });
59 |
60 | it('should accept array with multiple actions', (done) => {
61 | expect(actions.asyncActionCreator())
62 | .to.not.dispatch.actions(actions.anotherExpectedActions, done);
63 | });
64 |
65 | it('should accept array with nested async action creators', (done) => {
66 | expect(actions.parentAsyncActionCreator())
67 | .to.not.dispatch.actions(actions.anotherParentExpectedActions, done);
68 | });
69 | });
70 | });
71 |
72 | describe('should', () => {
73 | describe('.with.state', () => {
74 | it('should accept object', (done) => {
75 | actions.actionCreatorWithGetState().should
76 | .with.state({ property: 'value' })
77 | .dispatch.actions(actions.actionWithGetState({ property: 'value' }), done);
78 | });
79 |
80 | it('should accept function', (done) => {
81 | actions.actionCreatorWithGetState().should
82 | .with.state(() => { return { property: 'value' }; })
83 | .dispatch.actions(actions.actionWithGetState({ property: 'value' }), done);
84 | });
85 | });
86 |
87 | describe('.dispath.actions', () => {
88 | it('should accept single action', (done) => {
89 | actions.start().should
90 | .dispatch.actions(actions.start(), done);
91 | });
92 |
93 | it('should accept array with one action', (done) => {
94 | actions.start().should
95 | .dispatch.actions([actions.start()], done);
96 | });
97 |
98 | it('should accept array with multiple actions', (done) => {
99 | actions.asyncActionCreator().should
100 | .dispatch.actions(actions.expectedActions, done);
101 | });
102 |
103 | it('should accept array with nested async action creators', (done) => {
104 | actions.parentAsyncActionCreator().should
105 | .dispatch.actions(actions.expectedParentActions, done);
106 | });
107 | });
108 |
109 | describe('.not.dispath.actions', () => {
110 | it('should accept single action', (done) => {
111 | actions.start().should
112 | .not.dispatch.actions(actions.anotherStart(), done);
113 | });
114 |
115 | it('should accept array with one action', (done) => {
116 | actions.start().should
117 | .not.dispatch.actions([actions.anotherStart()], done);
118 | });
119 |
120 | it('should accept array with multiple actions', (done) => {
121 | actions.asyncActionCreator().should
122 | .not.dispatch.actions(actions.anotherExpectedActions, done);
123 | });
124 |
125 | it('should accept array with nested async action creators', (done) => {
126 | actions.parentAsyncActionCreator().should
127 | .not.dispatch.actions(actions.anotherParentExpectedActions, done);
128 | });
129 | });
130 | });
131 |
132 | describe('assert', () => {
133 | describe('isDispatchingWithState', () => {
134 | it('should accept object as third argument', (done) => {
135 | assert.isDispatchingWithState(
136 | actions.actionCreatorWithGetState(),
137 | actions.actionWithGetState({ property: 'value' }),
138 | { property: 'value' },
139 | done
140 | );
141 | });
142 |
143 | it('should accept function as third argument', (done) => {
144 | assert.isDispatchingWithState(
145 | actions.actionCreatorWithGetState(),
146 | actions.actionWithGetState({ property: 'value' }),
147 | () => { return { property: 'value' }; },
148 | done
149 | );
150 | });
151 | });
152 |
153 | describe('isNotDispatchingWithState', () => {
154 | it('should accept object as third argument', (done) => {
155 | assert.isNotDispatchingWithState(
156 | actions.actionCreatorWithGetState(),
157 | actions.actionWithGetState({ property: 'anotherParentAsyncActionCreator' }),
158 | { property: 'value' },
159 | done
160 | );
161 | });
162 |
163 | it('should accept function as third argument', (done) => {
164 | assert.isNotDispatchingWithState(
165 | actions.actionCreatorWithGetState(),
166 | actions.actionWithGetState({ property: 'anotherValue' }),
167 | () => { return { property: 'value' }; },
168 | done
169 | );
170 | });
171 | });
172 |
173 | describe('isDispatching', () => {
174 | it('should accept single action', (done) => {
175 | assert.isDispatching(
176 | actions.start(),
177 | actions.start(),
178 | done
179 | );
180 | });
181 |
182 | it('should accept array with one action', (done) => {
183 | assert.isDispatching(
184 | actions.start(),
185 | [actions.start()],
186 | done
187 | );
188 | });
189 |
190 | it('should accept array with multiple actions', (done) => {
191 | assert.isDispatching(
192 | actions.asyncActionCreator(),
193 | actions.expectedActions,
194 | done
195 | );
196 | });
197 |
198 | it('should accept array with nested async action creators', (done) => {
199 | assert.isDispatching(
200 | actions.parentAsyncActionCreator(),
201 | actions.expectedParentActions,
202 | done
203 | );
204 | });
205 | });
206 |
207 | describe('isNotDispatching', () => {
208 | it('should accept single action', (done) => {
209 | assert.isNotDispatching(
210 | actions.start(),
211 | actions.anotherStart(),
212 | done
213 | );
214 | });
215 |
216 | it('should accept array with one action', (done) => {
217 | assert.isNotDispatching(
218 | actions.start(),
219 | [actions.anotherStart()],
220 | done
221 | );
222 | });
223 |
224 | it('should accept array with multiple actions', (done) => {
225 | assert.isNotDispatching(
226 | actions.asyncActionCreator(),
227 | actions.anotherExpectedActions,
228 | done
229 | );
230 | });
231 |
232 | it('should accept array with nested async action creators', (done) => {
233 | assert.isNotDispatching(
234 | actions.parentAsyncActionCreator(),
235 | actions.anotherParentExpectedActions,
236 | done
237 | );
238 | });
239 | });
240 | });
241 | });
242 |
--------------------------------------------------------------------------------
/test/expect/index.js:
--------------------------------------------------------------------------------
1 | import expect from 'expect';
2 | import thunk from 'redux-thunk';
3 | import { registerMiddlewares } from '../../src';
4 | import { registerAssertions } from '../../src/expect';
5 | import actions from '../testingData/actions';
6 |
7 | registerMiddlewares([thunk]);
8 | registerAssertions();
9 |
10 | describe('expect', () => {
11 | describe('.withState', () => {
12 | it('should accept object', (done) => {
13 | expect(actions.actionCreatorWithGetState())
14 | .withState({ property: 'value' })
15 | .toDispatchActions(actions.actionWithGetState({ property: 'value' }), done);
16 | });
17 |
18 | it('should accept function', (done) => {
19 | expect(actions.actionCreatorWithGetState())
20 | .withState(() => { return { property: 'value' }; })
21 | .toDispatchActions(actions.actionWithGetState({ property: 'value' }), done);
22 | });
23 | });
24 |
25 | describe('.toDispatchActions', () => {
26 | it('should accept single action', (done) => {
27 | expect(actions.start()).toDispatchActions(actions.start(), done);
28 | });
29 |
30 | it('should accept array with one action', (done) => {
31 | expect(actions.start()).toDispatchActions([actions.start()], done);
32 | });
33 |
34 | it('should accept array with multiple actions', (done) => {
35 | expect(actions.asyncActionCreator())
36 | .toDispatchActions(actions.expectedActions, done);
37 | });
38 |
39 | it('should accept array with nested async action creators', (done) => {
40 | expect(actions.parentAsyncActionCreator())
41 | .toDispatchActions(actions.expectedParentActions, done);
42 | });
43 | });
44 |
45 | describe('.toNotDispatchActions', () => {
46 | it('should accept single action', (done) => {
47 | expect(actions.start()).toNotDispatchActions(actions.anotherStart(), done);
48 | });
49 |
50 | it('should accept array with one action', (done) => {
51 | expect(actions.start()).toNotDispatchActions([actions.anotherStart()], done);
52 | });
53 |
54 | it('should accept array with multiple actions', (done) => {
55 | expect(actions.asyncActionCreator())
56 | .toNotDispatchActions(actions.anotherExpectedActions, done);
57 | });
58 |
59 | it('should accept array with nested async action creators', (done) => {
60 | expect(actions.parentAsyncActionCreator())
61 | .toNotDispatchActions(actions.anotherParentExpectedActions, done);
62 | });
63 | });
64 | });
65 |
--------------------------------------------------------------------------------
/test/expectjs/index.js:
--------------------------------------------------------------------------------
1 | import expect from 'expect.js';
2 | import thunk from 'redux-thunk';
3 | import { registerMiddlewares } from '../../src';
4 | import { registerAssertions } from '../../src/expectjs';
5 | import actions from '../testingData/actions';
6 |
7 | registerMiddlewares([thunk]);
8 | registerAssertions();
9 |
10 | describe('expect.js', () => {
11 | describe('.withState', () => {
12 | it('should accept object', (done) => {
13 | expect(actions.actionCreatorWithGetState())
14 | .withState({ property: 'value' })
15 | .to.dispatchActions(actions.actionWithGetState({ property: 'value' }), done);
16 | });
17 |
18 | it('should accept function', (done) => {
19 | expect(actions.actionCreatorWithGetState())
20 | .withState(() => { return { property: 'value' }; })
21 | .to.dispatchActions(actions.actionWithGetState({ property: 'value' }), done);
22 | });
23 | });
24 |
25 | describe('.dispatchActions', () => {
26 | it('should accept single action', (done) => {
27 | expect(actions.start()).to.dispatchActions(actions.start(), done);
28 | });
29 |
30 | it('should accept array with one action', (done) => {
31 | expect(actions.start()).to.dispatchActions([actions.start()], done);
32 | });
33 |
34 | it('should accept array with multiple actions', (done) => {
35 | expect(actions.asyncActionCreator())
36 | .to.dispatchActions(actions.expectedActions, done);
37 | });
38 |
39 | it('should accept array with nested async action creators', (done) => {
40 | expect(actions.parentAsyncActionCreator())
41 | .to.dispatchActions(actions.expectedParentActions, done);
42 | });
43 | });
44 |
45 | describe('not.dispatchActions', () => {
46 | it('should accept single action', (done) => {
47 | expect(actions.start()).to.not.dispatchActions(actions.anotherStart(), done);
48 | });
49 |
50 | it('should accept array with one action', (done) => {
51 | expect(actions.start()).to.not.dispatchActions([actions.anotherStart()], done);
52 | });
53 |
54 | it('should accept array with multiple actions', (done) => {
55 | expect(actions.asyncActionCreator())
56 | .to.not.dispatchActions(actions.anotherExpectedActions, done);
57 | });
58 |
59 | it('should accept array with nested async action creators', (done) => {
60 | expect(actions.parentAsyncActionCreator())
61 | .to.not.dispatchActions(actions.anotherParentExpectedActions, done);
62 | });
63 | });
64 | });
65 |
--------------------------------------------------------------------------------
/test/index.js:
--------------------------------------------------------------------------------
1 | import expect from 'expect';
2 | import {
3 | registerMiddlewares,
4 | registerInitialStoreState,
5 | buildInitialStoreState,
6 | assertions
7 | } from '../src';
8 |
9 | describe('index', () => {
10 | it('should export registerMiddlewares', () => {
11 | expect(registerMiddlewares).toBeA('function');
12 | });
13 |
14 | it('should export registerInitialStoreState', () => {
15 | expect(registerInitialStoreState).toBeA('function');
16 | });
17 |
18 | it('should export buildInitialStoreState', () => {
19 | expect(buildInitialStoreState).toBeA('function');
20 | });
21 |
22 | it('should export assertions', () => {
23 | expect(assertions).toBeA('object');
24 | });
25 |
26 | it('should export toDispatchActions', () => {
27 | expect(assertions.toDispatchActions).toBeA('function');
28 | });
29 |
30 | it('should export toDispatchActionsWithState', () => {
31 | expect(assertions.toDispatchActionsWithState).toBeA('function');
32 | });
33 |
34 | it('should export toNotDispatchActions', () => {
35 | expect(assertions.toNotDispatchActions).toBeA('function');
36 | });
37 |
38 | it('should export toNotDispatchActionsWithState', () => {
39 | expect(assertions.toNotDispatchActionsWithState).toBeA('function');
40 | });
41 | });
42 |
--------------------------------------------------------------------------------
/test/jasmine/index.js:
--------------------------------------------------------------------------------
1 | /* eslint-env jasmine */
2 | import thunk from 'redux-thunk';
3 | import { registerMiddlewares } from '../../src';
4 | import { registerAssertions } from '../../src/jasmine';
5 | import actions from '../testingData/actions';
6 |
7 | registerMiddlewares([thunk]);
8 |
9 | beforeEach(registerAssertions);
10 |
11 | describe('jasmine', () => {
12 | describe('toDispatchActionsWithState', () => {
13 | it('should accept object', (done) => {
14 | const state = { property: 'value' };
15 | expect(actions.actionCreatorWithGetState())
16 | .toDispatchActionsWithState(state, actions.actionWithGetState({ property: 'value' }), done);
17 | });
18 | });
19 |
20 | describe('.toDispatchActions', () => {
21 | it('should accept single action', (done) => {
22 | expect(actions.start()).toDispatchActions(actions.start(), done);
23 | });
24 |
25 | it('should accept array with one action', (done) => {
26 | expect(actions.start()).toDispatchActions([actions.start()], done);
27 | });
28 |
29 | it('should accept array with multiple actions', (done) => {
30 | expect(actions.asyncActionCreator())
31 | .toDispatchActions(actions.expectedActions, done);
32 | });
33 |
34 | it('should accept array with nested async action creators', (done) => {
35 | expect(actions.parentAsyncActionCreator())
36 | .toDispatchActions(actions.expectedParentActions, done);
37 | });
38 | });
39 |
40 | describe('.toNotDispatchActions', () => {
41 | it('should accept single action', (done) => {
42 | expect(actions.start()).toNotDispatchActions(actions.anotherStart(), done);
43 | });
44 |
45 | it('should accept array with one action', (done) => {
46 | expect(actions.start()).toNotDispatchActions([actions.anotherStart()], done);
47 | });
48 |
49 | it('should accept array with multiple actions', (done) => {
50 | expect(actions.asyncActionCreator())
51 | .toNotDispatchActions(actions.anotherExpectedActions, done);
52 | });
53 |
54 | it('should accept array with nested async action creators', (done) => {
55 | expect(actions.parentAsyncActionCreator())
56 | .toNotDispatchActions(actions.anotherParentExpectedActions, done);
57 | });
58 | });
59 |
60 | describe('.not.toDispatchActions', () => {
61 | it('should accept single action', (done) => {
62 | expect(actions.start()).not.toDispatchActions(actions.anotherStart(), done);
63 | });
64 |
65 | it('should accept array with one action', (done) => {
66 | expect(actions.start()).not.toDispatchActions([actions.anotherStart()], done);
67 | });
68 |
69 | it('should accept array with multiple actions', (done) => {
70 | expect(actions.asyncActionCreator())
71 | .not.toDispatchActions(actions.anotherExpectedActions, done);
72 | });
73 |
74 | it('should accept array with nested async action creators', (done) => {
75 | expect(actions.parentAsyncActionCreator())
76 | .not.toDispatchActions(actions.anotherParentExpectedActions, done);
77 | });
78 | });
79 | });
80 |
--------------------------------------------------------------------------------
/test/jasmine/jasmine.json:
--------------------------------------------------------------------------------
1 | {
2 | "spec_dir": "test/jasmine",
3 | "spec_files": [
4 | "*.js"
5 | ],
6 | "helpers": [
7 | "../../node_modules/babel-register/lib/node.js"
8 | ]
9 | }
10 |
--------------------------------------------------------------------------------
/test/jest/index.js:
--------------------------------------------------------------------------------
1 | /* eslint-env jest */
2 | import thunk from 'redux-thunk';
3 | import { registerMiddlewares } from '../../src';
4 | import actions from '../testingData/actions';
5 |
6 | registerMiddlewares([thunk]);
7 |
8 | describe('jest', () => {
9 | describe('toDispatchActionsWithState', () => {
10 | it('should accept object', (done) => {
11 | const state = { property: 'value' };
12 | expect(actions.actionCreatorWithGetState())
13 | .toDispatchActionsWithState(state, actions.actionWithGetState({ property: 'value' }), done);
14 | });
15 | });
16 |
17 | describe('.toDispatchActions', () => {
18 | it('should accept single action', (done) => {
19 | expect(actions.start()).toDispatchActions(actions.start(), done);
20 | });
21 |
22 | it('should accept array with one action', (done) => {
23 | expect(actions.start()).toDispatchActions([actions.start()], done);
24 | });
25 |
26 | it('should accept array with multiple actions', (done) => {
27 | expect(actions.asyncActionCreator())
28 | .toDispatchActions(actions.expectedActions, done);
29 | });
30 |
31 | it('should accept array with nested async action creators', (done) => {
32 | expect(actions.parentAsyncActionCreator())
33 | .toDispatchActions(actions.expectedParentActions, done);
34 | });
35 | });
36 |
37 | describe('.toNotDispatchActions', () => {
38 | it('should accept single action', (done) => {
39 | expect(actions.start()).toNotDispatchActions(actions.anotherStart(), done);
40 | });
41 |
42 | it('should accept array with one action', (done) => {
43 | expect(actions.start()).toNotDispatchActions([actions.anotherStart()], done);
44 | });
45 |
46 | it('should accept array with multiple actions', (done) => {
47 | expect(actions.asyncActionCreator())
48 | .toNotDispatchActions(actions.anotherExpectedActions, done);
49 | });
50 |
51 | it('should accept array with nested async action creators', (done) => {
52 | expect(actions.parentAsyncActionCreator())
53 | .toNotDispatchActions(actions.anotherParentExpectedActions, done);
54 | });
55 | });
56 | });
57 |
--------------------------------------------------------------------------------
/test/jest/jest.json:
--------------------------------------------------------------------------------
1 | {
2 | "testPathDirs": ["/test/jest"],
3 | "testRegex": "index.js",
4 | "setupTestFrameworkScriptFile": "/test/jest/setupFramework.js"
5 | }
6 |
--------------------------------------------------------------------------------
/test/jest/setupFramework.js:
--------------------------------------------------------------------------------
1 | import { registerAssertions } from '../../src/jest';
2 |
3 | beforeEach(registerAssertions);
4 |
--------------------------------------------------------------------------------
/test/should/index.js:
--------------------------------------------------------------------------------
1 | import should from 'should';
2 | import thunk from 'redux-thunk';
3 | import { registerMiddlewares } from '../../src';
4 | import { registerAssertions } from '../../src/should';
5 | import actions from '../testingData/actions';
6 |
7 | registerMiddlewares([thunk]);
8 | registerAssertions();
9 |
10 | describe('should', () => {
11 | describe('.withState', () => {
12 | it('should accept object', (done) => {
13 | should(actions.actionCreatorWithGetState())
14 | .withState({ property: 'value' })
15 | .dispatchActions(actions.actionWithGetState({ property: 'value' }), done);
16 | });
17 |
18 | it('should accept function', (done) => {
19 | should(actions.actionCreatorWithGetState())
20 | .withState(() => { return { property: 'value' }; })
21 | .dispatchActions(actions.actionWithGetState({ property: 'value' }), done);
22 | });
23 |
24 | it('should work with .should', (done) => {
25 | actions.actionCreatorWithGetState().should
26 | .withState(() => { return { property: 'value' }; })
27 | .dispatchActions(actions.actionWithGetState({ property: 'value' }), done);
28 | });
29 |
30 | it('should have alias .state', (done) => {
31 | should(actions.actionCreatorWithGetState())
32 | .with.state(() => { return { property: 'value' }; })
33 | .dispatchActions(actions.actionWithGetState({ property: 'value' }), done);
34 | });
35 | });
36 |
37 | describe('.dispatchActions', () => {
38 | it('should accept single action', (done) => {
39 | should(actions.start()).dispatchActions(actions.start(), done);
40 | });
41 |
42 | it('should accept array with one action', (done) => {
43 | should(actions.start()).dispatchActions([actions.start()], done);
44 | });
45 |
46 | it('should accept array with multiple actions', (done) => {
47 | should(actions.asyncActionCreator())
48 | .dispatchActions(actions.expectedActions, done);
49 | });
50 |
51 | it('should accept array with nested async action creators', (done) => {
52 | should(actions.parentAsyncActionCreator())
53 | .dispatchActions(actions.expectedParentActions, done);
54 | });
55 |
56 | it('should work with .should', (done) => {
57 | actions.parentAsyncActionCreator().should
58 | .dispatchActions(actions.expectedParentActions, done);
59 | });
60 | });
61 |
62 | describe('.notDispatchActions', () => {
63 | it('should accept single action', (done) => {
64 | should(actions.start()).notDispatchActions(actions.anotherStart(), done);
65 | });
66 |
67 | it('should accept array with one action', (done) => {
68 | should(actions.start()).notDispatchActions([actions.anotherStart()], done);
69 | });
70 |
71 | it('should accept array with multiple actions', (done) => {
72 | should(actions.asyncActionCreator())
73 | .notDispatchActions(actions.anotherExpectedActions, done);
74 | });
75 |
76 | it('should accept array with nested async action creators', (done) => {
77 | should(actions.parentAsyncActionCreator())
78 | .notDispatchActions(actions.anotherParentExpectedActions, done);
79 | });
80 |
81 | it('should work with .should', (done) => {
82 | actions.parentAsyncActionCreator().should
83 | .notDispatchActions(actions.anotherParentExpectedActions, done);
84 | });
85 | });
86 | });
87 |
--------------------------------------------------------------------------------
/test/tape/index.js:
--------------------------------------------------------------------------------
1 | import test from 'tape';
2 | import thunk from 'redux-thunk';
3 |
4 | import { assertions, registerMiddlewares } from '../../src';
5 | import actions from '../testingData/actions';
6 |
7 | registerMiddlewares([thunk]);
8 |
9 | test('tape', t => {
10 | t.plan(1);
11 | const msg = 'should pass with t.plan';
12 |
13 | assertions.toDispatchActionsWithState(
14 | { property: 'value' },
15 | actions.actionCreatorWithGetState(),
16 | actions.actionWithGetState({ property: 'value' }),
17 | t.pass.bind(this, msg),
18 | t.fail.bind(this, msg)
19 | );
20 | });
21 |
22 | test('tape', t => {
23 | const msg = 'should pass with t.end';
24 |
25 | assertions.toDispatchActionsWithState(
26 | { property: 'value' },
27 | actions.actionCreatorWithGetState(),
28 | actions.actionWithGetState({ property: 'value' }),
29 | t.pass.bind(this, msg),
30 | t.fail.bind(this, msg)
31 | ).then(t.end);
32 | });
33 |
--------------------------------------------------------------------------------
/test/testingData/actions.js:
--------------------------------------------------------------------------------
1 | function asyncFunction() {
2 | return Promise.resolve();
3 | }
4 |
5 | const start = () => { return { type: 'test-action-start' }; };
6 | const anotherStart = () => { return { type: 'test-action-another-start' }; };
7 | const finish = () => { return { type: 'test-action-finish' }; };
8 | const fail = () => { return { type: 'test-action-fail' }; };
9 |
10 | const actionWithGetState = (data) => { return { type: 'test-action-with-get-state', data }; };
11 |
12 | function actionCreatorWithGetState() {
13 | return (dispatch, getState) => {
14 | dispatch(actionWithGetState(getState()));
15 | };
16 | }
17 |
18 | function asyncActionCreator() {
19 | return dispatch => {
20 | dispatch(start());
21 | dispatch(anotherStart());
22 | return asyncFunction().then(() => {
23 | dispatch(finish());
24 | }).catch(() => {
25 | dispatch(fail());
26 | });
27 | };
28 | }
29 |
30 | const parentStart = () => { return { type: 'parent-test-action-start' }; };
31 | const parentFinish = () => { return { type: 'parent-test-action-finish' }; };
32 | const parentFail = () => { return { type: 'parent-test-action-fail' }; };
33 |
34 | function parentAsyncActionCreator() {
35 | return dispatch => {
36 | dispatch(parentStart());
37 | return asyncFunction().then(() => {
38 | dispatch(asyncActionCreator());
39 | dispatch(parentFinish());
40 | }, () => {
41 | dispatch(parentFail());
42 | });
43 | };
44 | }
45 |
46 | const anotherAsyncStart = () => { return { type: 'another-test-action-start' }; };
47 | const anotherAsyncFinish = () => { return { type: 'another-test-action-finish' }; };
48 | const anotherAsyncFail = () => { return { type: 'another-test-action-fail' }; };
49 |
50 | function anotherAsyncActionCreator() {
51 | return dispatch => {
52 | dispatch(anotherAsyncStart());
53 | return asyncFunction().then(() => {
54 | dispatch(anotherAsyncFinish());
55 | }).catch(() => {
56 | dispatch(anotherAsyncFail());
57 | });
58 | };
59 | }
60 |
61 | const anotherParentAsyncStart = () => { return { type: 'another-parent-test-action-start' }; };
62 | const anotherParentAsyncFinish = () => { return { type: 'another-parent-test-action-finish' }; };
63 | const anotherParentAsyncFail = () => { return { type: 'another-parent-test-action-fail' }; };
64 |
65 | function anotherParentAsyncActionCreator() {
66 | return dispatch => {
67 | dispatch(anotherParentAsyncStart());
68 | return asyncFunction().then(() => {
69 | dispatch(anotherAsyncActionCreator());
70 | dispatch(anotherParentAsyncFinish());
71 | }, () => {
72 | dispatch(anotherParentAsyncFail());
73 | });
74 | };
75 | }
76 |
77 | const expectedActions = [
78 | start(),
79 | anotherStart(),
80 | finish()
81 | ];
82 |
83 | const expectedParentActions = [
84 | parentStart(),
85 | asyncActionCreator(),
86 | parentFinish()
87 | ];
88 |
89 |
90 | const anotherExpectedActions = [
91 | anotherAsyncStart(),
92 | anotherAsyncFinish()
93 | ];
94 |
95 | const anotherParentExpectedActions = [
96 | anotherParentAsyncStart(),
97 | anotherAsyncActionCreator(),
98 | anotherParentAsyncFail()
99 | ];
100 |
101 |
102 | export default {
103 | start,
104 | anotherStart,
105 | finish,
106 | fail,
107 | actionWithGetState,
108 | actionCreatorWithGetState,
109 | asyncActionCreator,
110 | parentStart,
111 | parentFinish,
112 | parentFail,
113 | parentAsyncActionCreator,
114 | expectedActions,
115 | expectedParentActions,
116 | anotherAsyncActionCreator,
117 | anotherParentAsyncActionCreator,
118 | anotherExpectedActions,
119 | anotherParentExpectedActions
120 | };
121 |
--------------------------------------------------------------------------------
/test/testingData/reducers.js:
--------------------------------------------------------------------------------
1 | import { combineReducers } from 'redux';
2 |
3 | const state1 = {
4 | testKey1: 'testValue1'
5 | };
6 |
7 | const state2 = {
8 | testKey2: 'testValue2'
9 | };
10 |
11 | const expectedInitialState = {
12 | reducerWithInitialState1: {
13 | testKey1: 'testValue1'
14 | },
15 | reducerWithInitialState2: {
16 | testKey2: 'testValue2'
17 | }
18 | };
19 |
20 | function reducerWithInitialState1(state = state1) {
21 | return state;
22 | }
23 |
24 |
25 | function reducerWithInitialState2(state = state2) {
26 | return state;
27 | }
28 |
29 | const reducerWithNesterReducers = combineReducers({
30 | reducerWithInitialState1,
31 | reducerWithInitialState2
32 | });
33 |
34 | export { expectedInitialState, reducerWithNesterReducers };
35 |
--------------------------------------------------------------------------------