UNPKG

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