|
| 1 | +<!DOCTYPE HTML> |
| 2 | +<html lang="en" > |
| 3 | + |
| 4 | + <head> |
| 5 | + |
| 6 | + <meta charset="UTF-8"> |
| 7 | + <meta http-equiv="X-UA-Compatible" content="IE=edge" /> |
| 8 | + <title>chai | Redux Actions Assertions</title> |
| 9 | + <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> |
| 10 | + <meta name="description" content=""> |
| 11 | + <meta name="generator" content="GitBook 2.6.7"> |
| 12 | + |
| 13 | + |
| 14 | + <meta name="HandheldFriendly" content="true"/> |
| 15 | + <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> |
| 16 | + <meta name="apple-mobile-web-app-capable" content="yes"> |
| 17 | + <meta name="apple-mobile-web-app-status-bar-style" content="black"> |
| 18 | + <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png"> |
| 19 | + <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon"> |
| 20 | + |
| 21 | + <link rel="stylesheet" href="gitbook/style.css"> |
| 22 | + |
| 23 | + |
| 24 | + <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-highlight/website.css"> |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-search/search.css"> |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-fontsettings/website.css"> |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + <link rel="next" href="./expect.html" /> |
| 41 | + |
| 42 | + |
| 43 | + <link rel="prev" href="./javascript.html" /> |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + </head> |
| 48 | + <body> |
| 49 | + |
| 50 | + |
| 51 | + <div class="book" |
| 52 | + data-level="3.1" |
| 53 | + data-chapter-title="chai" |
| 54 | + data-filepath="chai.md" |
| 55 | + data-basepath="." |
| 56 | + data-revision="Thu Sep 22 2016 18:44:55 GMT+0200 (CEST)" |
| 57 | + data-innerlanguage=""> |
| 58 | + |
| 59 | + |
| 60 | +<div class="book-summary"> |
| 61 | + <nav role="navigation"> |
| 62 | + <ul class="summary"> |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + <li class="chapter " data-level="0" data-path="index.html"> |
| 73 | + |
| 74 | + |
| 75 | + <a href="./index.html"> |
| 76 | + |
| 77 | + <i class="fa fa-check"></i> |
| 78 | + |
| 79 | + Introduction |
| 80 | + </a> |
| 81 | + |
| 82 | + |
| 83 | + </li> |
| 84 | + |
| 85 | + <li class="chapter " data-level="1" data-path="what_it_does.html"> |
| 86 | + |
| 87 | + |
| 88 | + <a href="./what_it_does.html"> |
| 89 | + |
| 90 | + <i class="fa fa-check"></i> |
| 91 | + |
| 92 | + <b>1.</b> |
| 93 | + |
| 94 | + What it does |
| 95 | + </a> |
| 96 | + |
| 97 | + |
| 98 | + </li> |
| 99 | + |
| 100 | + <li class="chapter " data-level="2" data-path="installation.html"> |
| 101 | + |
| 102 | + |
| 103 | + <a href="./installation.html"> |
| 104 | + |
| 105 | + <i class="fa fa-check"></i> |
| 106 | + |
| 107 | + <b>2.</b> |
| 108 | + |
| 109 | + Installation |
| 110 | + </a> |
| 111 | + |
| 112 | + |
| 113 | + </li> |
| 114 | + |
| 115 | + <li class="chapter " data-level="3" data-path="javascript.html"> |
| 116 | + |
| 117 | + |
| 118 | + <a href="./javascript.html"> |
| 119 | + |
| 120 | + <i class="fa fa-check"></i> |
| 121 | + |
| 122 | + <b>3.</b> |
| 123 | + |
| 124 | + API Reference |
| 125 | + </a> |
| 126 | + |
| 127 | + |
| 128 | + <ul class="articles"> |
| 129 | + |
| 130 | + |
| 131 | + <li class="chapter active" data-level="3.1" data-path="chai.html"> |
| 132 | + |
| 133 | + |
| 134 | + <a href="./chai.html"> |
| 135 | + |
| 136 | + <i class="fa fa-check"></i> |
| 137 | + |
| 138 | + <b>3.1.</b> |
| 139 | + |
| 140 | + chai |
| 141 | + </a> |
| 142 | + |
| 143 | + |
| 144 | + </li> |
| 145 | + |
| 146 | + <li class="chapter " data-level="3.2" data-path="expect.html"> |
| 147 | + |
| 148 | + |
| 149 | + <a href="./expect.html"> |
| 150 | + |
| 151 | + <i class="fa fa-check"></i> |
| 152 | + |
| 153 | + <b>3.2.</b> |
| 154 | + |
| 155 | + expect |
| 156 | + </a> |
| 157 | + |
| 158 | + |
| 159 | + </li> |
| 160 | + |
| 161 | + <li class="chapter " data-level="3.3" data-path="expectjs.html"> |
| 162 | + |
| 163 | + |
| 164 | + <a href="./expectjs.html"> |
| 165 | + |
| 166 | + <i class="fa fa-check"></i> |
| 167 | + |
| 168 | + <b>3.3.</b> |
| 169 | + |
| 170 | + expect.js |
| 171 | + </a> |
| 172 | + |
| 173 | + |
| 174 | + </li> |
| 175 | + |
| 176 | + <li class="chapter " data-level="3.4" data-path="should.html"> |
| 177 | + |
| 178 | + |
| 179 | + <a href="./should.html"> |
| 180 | + |
| 181 | + <i class="fa fa-check"></i> |
| 182 | + |
| 183 | + <b>3.4.</b> |
| 184 | + |
| 185 | + should |
| 186 | + </a> |
| 187 | + |
| 188 | + |
| 189 | + </li> |
| 190 | + |
| 191 | + <li class="chapter " data-level="3.5" data-path="tape.html"> |
| 192 | + |
| 193 | + |
| 194 | + <a href="./tape.html"> |
| 195 | + |
| 196 | + <i class="fa fa-check"></i> |
| 197 | + |
| 198 | + <b>3.5.</b> |
| 199 | + |
| 200 | + tape |
| 201 | + </a> |
| 202 | + |
| 203 | + |
| 204 | + </li> |
| 205 | + |
| 206 | + |
| 207 | + </ul> |
| 208 | + |
| 209 | + </li> |
| 210 | + |
| 211 | + |
| 212 | + |
| 213 | + |
| 214 | + <li class="divider"></li> |
| 215 | + <li> |
| 216 | + <a href="https://www.gitbook.com" target="blank" class="gitbook-link"> |
| 217 | + Published with GitBook |
| 218 | + </a> |
| 219 | + </li> |
| 220 | + |
| 221 | + </ul> |
| 222 | + </nav> |
| 223 | +</div> |
| 224 | + |
| 225 | + <div class="book-body"> |
| 226 | + <div class="body-inner"> |
| 227 | + <div class="book-header" role="navigation"> |
| 228 | + <!-- Actions Left --> |
| 229 | + |
| 230 | + |
| 231 | + <!-- Title --> |
| 232 | + <h1> |
| 233 | + <i class="fa fa-circle-o-notch fa-spin"></i> |
| 234 | + <a href="./" >Redux Actions Assertions</a> |
| 235 | + </h1> |
| 236 | +</div> |
| 237 | + |
| 238 | + <div class="page-wrapper" tabindex="-1" role="main"> |
| 239 | + <div class="page-inner"> |
| 240 | + |
| 241 | + |
| 242 | + <section class="normal" id="section-"> |
| 243 | + |
| 244 | + <h1 id="chai"><a href="https://github.com/chaijs/chai" target="_blank">chai</a></h1> |
| 245 | +<h2 id="registration">Registration</h2> |
| 246 | +<pre><code class="lang-js"><span class="hljs-comment">// using ES6 modules</span> |
| 247 | +<span class="hljs-keyword">import</span> { registerAssertions } <span class="hljs-keyword">from</span> <span class="hljs-string">'redux-actions-assertions/chai'</span>; |
| 248 | + |
| 249 | +<span class="hljs-comment">// using CommonJS modules</span> |
| 250 | +<span class="hljs-keyword">var</span> registerAssertions = <span class="hljs-built_in">require</span>(<span class="hljs-string">'redux-actions-assertions/chai'</span>).registerAssertions; |
| 251 | + |
| 252 | +<span class="hljs-comment">// registration</span> |
| 253 | +registerAssertions(); |
| 254 | +</code></pre> |
| 255 | +<h2 id="usage">Usage</h2> |
| 256 | +<h3 id="todispatchactions-or-assertisdispatching">.to.dispatch.actions or assert.isDispatching</h3> |
| 257 | +<blockquote> |
| 258 | +<p><code>expect(action).to.dispatch.actions(expectedActions, callback)</code></p> |
| 259 | +<p><code>action.should.dispatch.actions(expectedActions, callback)</code></p> |
| 260 | +<p><code>assert.isDispatching(action, expectedActions, callback)</code></p> |
| 261 | +</blockquote> |
| 262 | +<p>Asserts that when given <code>action</code> is dispatched it will dispatch <code>expectedActions</code>. <code>action</code> can be plain object (action) or function (action creator). <code>expectedActions</code> can be can be plain object (action) or function (action creator) or array of objects/functions.</p> |
| 263 | +<pre><code class="lang-js">expect(myActionCreator()) |
| 264 | + .to.dispatch.actions({ type: <span class="hljs-string">'MY_ACTION_START'</span> }, callback); |
| 265 | + |
| 266 | +myActionCreator() |
| 267 | + .should.dispatch.actions({ type: <span class="hljs-string">'MY_ACTION_START'</span> }, callback); |
| 268 | + |
| 269 | +assert.isDispatching( |
| 270 | + myActionCreator(), |
| 271 | + { type: <span class="hljs-string">'MY_ACTION_START'</span> }, |
| 272 | + callback |
| 273 | +); |
| 274 | +</code></pre> |
| 275 | +<h3 id="nottodispatchactions-or-tonotdispatchactions-or-assertisnotdispatching">.not.to.dispatch.actions or .to.not.dispatch.actions or assert.isNotDispatching</h3> |
| 276 | +<blockquote> |
| 277 | +<p><code>expect(action).not.to.dispatch.actions(expectedActions, callback)</code> |
| 278 | +<code>expect(action).to.not.dispatch.actions(expectedActions, callback)</code></p> |
| 279 | +<p><code>action.should.not.dispatch.actions(expectedActions, callback)</code></p> |
| 280 | +<p><code>assert.isNotDispatching(action, expectedActions, callback)</code></p> |
| 281 | +</blockquote> |
| 282 | +<p>Asserts that when given <code>action</code> is dispatched it will not dispatch <code>expectedActions</code>. <code>action</code> can be plain object (action) or function (action creator). <code>expectedActions</code> can be can be plain object (action) or function (action creator) or array of objects/functions.</p> |
| 283 | +<pre><code class="lang-js">expect(myActionCreator()) |
| 284 | + .not.to.dispatch.actions({ type: <span class="hljs-string">'MY_ACTION_START'</span> }, callback); |
| 285 | + |
| 286 | +myActionCreator() |
| 287 | + .should.not.dispatch.actions({ type: <span class="hljs-string">'MY_ACTION_START'</span> }, callback); |
| 288 | + |
| 289 | +assert.isNotDispatching( |
| 290 | + myActionCreator(), |
| 291 | + { type: <span class="hljs-string">'MY_ACTION_START'</span> }, |
| 292 | + callback |
| 293 | +); |
| 294 | +</code></pre> |
| 295 | +<h3 id="withstate-or-assertisdispatchingwithstate-and-assertisnotdispatchingwithstate">.with.state or assert.isDispatchingWithState and assert.isNotDispatchingWithState</h3> |
| 296 | +<blockquote> |
| 297 | +<p><code>expect(action).with.state(state).to.dispatch.actions(expectedActions, callback)</code> |
| 298 | +<code>expect(action).with.state(state).not.to.dispatch.actions(expectedActions, callback)</code> |
| 299 | +<code>expect(action).with.state(state).to.not.dispatch.actions(expectedActions, callback)</code></p> |
| 300 | +<p><code>action.should.with.state(state).dispatch.actions(expectedActions, callback)</code> |
| 301 | +<code>action.should.with.state(state).not.dispatch.actions(expectedActions, callback)</code></p> |
| 302 | +<p><code>assert.isDispatchingWithState(action, expectedActions, state, callback)</code> |
| 303 | +<code>assert.isNotDispatchingWithState(action, expectedActions, state, callback)</code></p> |
| 304 | +</blockquote> |
| 305 | +<p>Asserts that store initialised with <code>state</code> before <code>action</code> is dispatched.</p> |
| 306 | +<pre><code class="lang-js">expect(myActionCreator()) |
| 307 | + .with.state({ property: <span class="hljs-string">'value'</span> }) |
| 308 | + .to.dispatch.actions([{ type: <span class="hljs-string">'MY_ACTION_START'</span> }, finishActionCreator()], callback); |
| 309 | + |
| 310 | +myActionCreator() |
| 311 | + .should.with.({ property: <span class="hljs-string">'value'</span> }) |
| 312 | + .dispatch.actions([{ type: <span class="hljs-string">'MY_ACTION_START'</span> }, finishActionCreator()], callback); |
| 313 | + |
| 314 | +assert.isDispatchingWithState( |
| 315 | + myActionCreator(), |
| 316 | + [{ type: <span class="hljs-string">'MY_ACTION_START'</span> }, finishActionCreator()], |
| 317 | + { property: <span class="hljs-string">'value'</span> } |
| 318 | + callback |
| 319 | +); |
| 320 | + |
| 321 | +assert.isNotDispatchingWithState( |
| 322 | + myActionCreator(), |
| 323 | + [{ type: <span class="hljs-string">'MY_ACTION_START'</span> }, finishActionCreator()], |
| 324 | + { property: <span class="hljs-string">'value'</span> } |
| 325 | + callback |
| 326 | +); |
| 327 | +</code></pre> |
| 328 | + |
| 329 | + |
| 330 | + </section> |
| 331 | + |
| 332 | + |
| 333 | + </div> |
| 334 | + </div> |
| 335 | + </div> |
| 336 | + |
| 337 | + |
| 338 | + <a href="./javascript.html" class="navigation navigation-prev " aria-label="Previous page: API Reference"><i class="fa fa-angle-left"></i></a> |
| 339 | + |
| 340 | + |
| 341 | + <a href="./expect.html" class="navigation navigation-next " aria-label="Next page: expect"><i class="fa fa-angle-right"></i></a> |
| 342 | + |
| 343 | + </div> |
| 344 | +</div> |
| 345 | + |
| 346 | + |
| 347 | +<script src="gitbook/app.js"></script> |
| 348 | + |
| 349 | + |
| 350 | + <script src="gitbook/plugins/gitbook-plugin-ga/plugin.js"></script> |
| 351 | + |
| 352 | + |
| 353 | + |
| 354 | + <script src="gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script> |
| 355 | + |
| 356 | + |
| 357 | + |
| 358 | + <script src="gitbook/plugins/gitbook-plugin-search/search.js"></script> |
| 359 | + |
| 360 | + |
| 361 | + |
| 362 | + <script src="gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script> |
| 363 | + |
| 364 | + |
| 365 | + |
| 366 | + <script src="gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script> |
| 367 | + |
| 368 | + |
| 369 | +<script> |
| 370 | +require(["gitbook"], function(gitbook) { |
| 371 | + var config = {"ga":{"token":"UA-78823490-1","configuration":"auto"},"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":false,"twitter":false,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"],"website":false},"fontsettings":{"theme":"white","family":"sans","size":2}}; |
| 372 | + gitbook.start(config); |
| 373 | +}); |
| 374 | +</script> |
| 375 | + |
| 376 | + |
| 377 | + </body> |
| 378 | + |
| 379 | +</html> |
0 commit comments