UNPKG

4.88 kBJavaScriptView Raw
1"use strict";
2
3var _recompose = require("recompose");
4
5var _asyncReductions = require("./async-reductions");
6
7test('setAsyncTrueReduction', function () {
8 expect((0, _asyncReductions.setAsyncTrueReduction)('a')({})).toEqual({
9 a: true
10 });
11 expect((0, _recompose.compose)((0, _asyncReductions.setAsyncTrueReduction)('a'))({})).toEqual({
12 a: true
13 });
14});
15test('setAsyncPageTrueReduction', function () {
16 expect((0, _asyncReductions.setAsyncPageTrueReduction)()({})).toEqual({
17 page: true
18 });
19 expect((0, _recompose.compose)((0, _asyncReductions.setAsyncPageTrueReduction)())({})).toEqual({
20 page: true
21 });
22});
23test('setAsyncTrueReductionFromAsyncKeyProp', function () {
24 expect((0, _asyncReductions.setAsyncTrueReductionFromAsyncKeyProp)({
25 asyncKey: 'a'
26 })({})).toEqual({
27 a: true
28 });
29 expect((0, _recompose.compose)((0, _asyncReductions.setAsyncTrueReductionFromAsyncKeyProp)({
30 asyncKey: 'a'
31 }))({})).toEqual({
32 a: true
33 });
34});
35test('setAsyncRequestReduction', function () {
36 expect((0, _asyncReductions.setAsyncRequestReduction)('a')({})).toEqual({
37 a: _asyncReductions.REQUEST
38 });
39 expect((0, _recompose.compose)((0, _asyncReductions.setAsyncRequestReduction)('a'))({})).toEqual({
40 a: _asyncReductions.REQUEST
41 });
42});
43test('setAsyncRequestReductionFromAsyncKeyProp', function () {
44 expect((0, _asyncReductions.setAsyncRequestReductionFromAsyncKeyProp)({
45 asyncKey: 'a'
46 })({})).toEqual({
47 a: _asyncReductions.REQUEST
48 });
49 expect((0, _recompose.compose)((0, _asyncReductions.setAsyncRequestReductionFromAsyncKeyProp)({
50 asyncKey: 'a'
51 }))({})).toEqual({
52 a: _asyncReductions.REQUEST
53 });
54});
55test('setAsyncSuccessReduction', function () {
56 expect((0, _asyncReductions.setAsyncSuccessReduction)('a')({})).toEqual({
57 a: _asyncReductions.SUCCESS
58 });
59 expect((0, _recompose.compose)((0, _asyncReductions.setAsyncSuccessReduction)('a'))({})).toEqual({
60 a: _asyncReductions.SUCCESS
61 });
62});
63test('setAsyncSuccessReductionFromAsyncKeyProp', function () {
64 expect((0, _asyncReductions.setAsyncSuccessReductionFromAsyncKeyProp)({
65 asyncKey: 'a'
66 })({})).toEqual({
67 a: _asyncReductions.SUCCESS
68 });
69 expect((0, _recompose.compose)((0, _asyncReductions.setAsyncSuccessReductionFromAsyncKeyProp)({
70 asyncKey: 'a'
71 }))({})).toEqual({
72 a: _asyncReductions.SUCCESS
73 });
74});
75test('setAsyncFailureReduction', function () {
76 expect((0, _asyncReductions.setAsyncFailureReduction)('a')({})).toEqual({
77 a: _asyncReductions.FAILURE
78 });
79 expect((0, _recompose.compose)((0, _asyncReductions.setAsyncFailureReduction)('a'))({})).toEqual({
80 a: _asyncReductions.FAILURE
81 });
82});
83test('setAsyncFailureReductionFromAsyncKeyProp', function () {
84 expect((0, _asyncReductions.setAsyncFailureReductionFromAsyncKeyProp)({
85 asyncKey: 'a'
86 })({})).toEqual({
87 a: _asyncReductions.FAILURE
88 });
89 expect((0, _recompose.compose)((0, _asyncReductions.setAsyncFailureReductionFromAsyncKeyProp)({
90 asyncKey: 'a'
91 }))({})).toEqual({
92 a: _asyncReductions.FAILURE
93 });
94});
95test('setAsyncCustomReductionFromProps', function () {
96 expect((0, _asyncReductions.setAsyncCustomReductionFromProps)({
97 asyncKey: 'a',
98 asyncValue: 'custom'
99 })({})).toEqual({
100 a: 'custom'
101 });
102 expect((0, _recompose.compose)((0, _asyncReductions.setAsyncCustomReductionFromProps)({
103 asyncKey: 'a',
104 asyncValue: 'custom'
105 }))({})).toEqual({
106 a: 'custom'
107 });
108});
109test('delAsyncReduction', function () {
110 var asyncState = {
111 foo: 'foo',
112 bar: 'bar'
113 };
114 expect((0, _asyncReductions.delAsyncReduction)('foo')(asyncState)).toEqual({
115 bar: 'bar'
116 });
117 expect((0, _recompose.compose)((0, _asyncReductions.delAsyncReduction)('foo'))(asyncState)).toEqual({
118 bar: 'bar'
119 });
120});
121test('delAsyncPageReduction', function () {
122 var asyncState = {
123 page: 'page',
124 bar: 'bar'
125 };
126 expect((0, _asyncReductions.delAsyncPageReduction)()(asyncState)).toEqual({
127 bar: 'bar'
128 });
129 expect((0, _recompose.compose)((0, _asyncReductions.delAsyncPageReduction)())(asyncState)).toEqual({
130 bar: 'bar'
131 });
132});
133test('delAsyncReductionFromAsyncKeyProp', function () {
134 var asyncState = {
135 foo: 'foo',
136 bar: 'bar'
137 };
138 expect((0, _asyncReductions.delAsyncReductionFromAsyncKeyProp)({
139 asyncKey: 'foo'
140 })(asyncState)).toEqual({
141 bar: 'bar'
142 });
143 expect((0, _recompose.compose)((0, _asyncReductions.delAsyncReductionFromAsyncKeyProp)({
144 asyncKey: 'foo'
145 }))(asyncState)).toEqual({
146 bar: 'bar'
147 });
148});
149test('clearAsyncExceptPageReduction', function () {
150 var asyncState = {
151 page: 'page',
152 foo: 'foo'
153 };
154 expect((0, _asyncReductions.clearAsyncExceptPageReduction)()(asyncState)).toEqual({
155 page: 'page'
156 });
157 expect((0, _recompose.compose)((0, _asyncReductions.clearAsyncExceptPageReduction)())(asyncState)).toEqual({
158 page: 'page'
159 });
160});
\No newline at end of file