1 | 'use strict';
|
2 |
|
3 | var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
|
4 |
|
5 | var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
|
6 |
|
7 | var _ava = require('ava');
|
8 |
|
9 | var _ava2 = _interopRequireDefault(_ava);
|
10 |
|
11 | var _parse = require('@commitlint/parse');
|
12 |
|
13 | var _parse2 = _interopRequireDefault(_parse);
|
14 |
|
15 | var _scopeEnum27 = require('./scope-enum');
|
16 |
|
17 | var _scopeEnum28 = _interopRequireDefault(_scopeEnum27);
|
18 |
|
19 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
20 |
|
21 | var messages = {
|
22 | plain: 'foo(bar): baz',
|
23 | superfluous: 'foo(): baz',
|
24 | empty: 'foo: baz'
|
25 | };
|
26 |
|
27 | var parsed = {
|
28 | plain: (0, _parse2.default)(messages.plain),
|
29 | superfluous: (0, _parse2.default)(messages.superfluous),
|
30 | empty: (0, _parse2.default)(messages.empty)
|
31 | };
|
32 |
|
33 | (0, _ava2.default)('scope-enum with plain message and always should succeed empty enum', function (t) {
|
34 | return new Promise(function ($return, $error) {
|
35 | var _scopeEnum, _scopeEnum2, actual, expected;
|
36 |
|
37 | return Promise.resolve(parsed.plain).then(function ($await_1) {
|
38 | try {
|
39 | _scopeEnum = (0, _scopeEnum28.default)($await_1, 'always', []), _scopeEnum2 = (0, _slicedToArray3.default)(_scopeEnum, 1), actual = _scopeEnum2[0];
|
40 |
|
41 | expected = true;
|
42 | t.deepEqual(actual, expected);
|
43 | return $return();
|
44 | } catch ($boundEx) {
|
45 | return $error($boundEx);
|
46 | }
|
47 | }.bind(this), $error);
|
48 | }.bind(this));
|
49 | });
|
50 |
|
51 | (0, _ava2.default)('scope-enum with plain message and never should error empty enum', function (t) {
|
52 | return new Promise(function ($return, $error) {
|
53 | var _scopeEnum3, _scopeEnum4, actual, expected;
|
54 |
|
55 | return Promise.resolve(parsed.plain).then(function ($await_2) {
|
56 | try {
|
57 | _scopeEnum3 = (0, _scopeEnum28.default)($await_2, 'never', []), _scopeEnum4 = (0, _slicedToArray3.default)(_scopeEnum3, 1), actual = _scopeEnum4[0];
|
58 |
|
59 | expected = false;
|
60 | t.deepEqual(actual, expected);
|
61 | return $return();
|
62 | } catch ($boundEx) {
|
63 | return $error($boundEx);
|
64 | }
|
65 | }.bind(this), $error);
|
66 | }.bind(this));
|
67 | });
|
68 |
|
69 | (0, _ava2.default)('with plain message should succeed correct enum', function (t) {
|
70 | return new Promise(function ($return, $error) {
|
71 | var _scopeEnum5, _scopeEnum6, actual, expected;
|
72 |
|
73 | return Promise.resolve(parsed.plain).then(function ($await_3) {
|
74 | try {
|
75 | _scopeEnum5 = (0, _scopeEnum28.default)($await_3, 'always', ['bar']), _scopeEnum6 = (0, _slicedToArray3.default)(_scopeEnum5, 1), actual = _scopeEnum6[0];
|
76 |
|
77 | expected = true;
|
78 | t.deepEqual(actual, expected);
|
79 | return $return();
|
80 | } catch ($boundEx) {
|
81 | return $error($boundEx);
|
82 | }
|
83 | }.bind(this), $error);
|
84 | }.bind(this));
|
85 | });
|
86 |
|
87 | (0, _ava2.default)('scope-enum with plain message should error false enum', function (t) {
|
88 | return new Promise(function ($return, $error) {
|
89 | var _scopeEnum7, _scopeEnum8, actual, expected;
|
90 |
|
91 | return Promise.resolve(parsed.plain).then(function ($await_4) {
|
92 | try {
|
93 | _scopeEnum7 = (0, _scopeEnum28.default)($await_4, 'always', ['foo']), _scopeEnum8 = (0, _slicedToArray3.default)(_scopeEnum7, 1), actual = _scopeEnum8[0];
|
94 |
|
95 | expected = false;
|
96 | t.deepEqual(actual, expected);
|
97 | return $return();
|
98 | } catch ($boundEx) {
|
99 | return $error($boundEx);
|
100 | }
|
101 | }.bind(this), $error);
|
102 | }.bind(this));
|
103 | });
|
104 |
|
105 | (0, _ava2.default)('scope-enum with plain message should error forbidden enum', function (t) {
|
106 | return new Promise(function ($return, $error) {
|
107 | var _scopeEnum9, _scopeEnum10, actual, expected;
|
108 |
|
109 | return Promise.resolve(parsed.plain).then(function ($await_5) {
|
110 | try {
|
111 | _scopeEnum9 = (0, _scopeEnum28.default)($await_5, 'never', ['bar']), _scopeEnum10 = (0, _slicedToArray3.default)(_scopeEnum9, 1), actual = _scopeEnum10[0];
|
112 |
|
113 | expected = false;
|
114 | t.deepEqual(actual, expected);
|
115 | return $return();
|
116 | } catch ($boundEx) {
|
117 | return $error($boundEx);
|
118 | }
|
119 | }.bind(this), $error);
|
120 | }.bind(this));
|
121 | });
|
122 |
|
123 | (0, _ava2.default)('scope-enum with plain message should succeed forbidden enum', function (t) {
|
124 | return new Promise(function ($return, $error) {
|
125 | var _scopeEnum11, _scopeEnum12, actual, expected;
|
126 |
|
127 | return Promise.resolve(parsed.plain).then(function ($await_6) {
|
128 | try {
|
129 | _scopeEnum11 = (0, _scopeEnum28.default)($await_6, 'never', ['foo']), _scopeEnum12 = (0, _slicedToArray3.default)(_scopeEnum11, 1), actual = _scopeEnum12[0];
|
130 |
|
131 | expected = true;
|
132 | t.deepEqual(actual, expected);
|
133 | return $return();
|
134 | } catch ($boundEx) {
|
135 | return $error($boundEx);
|
136 | }
|
137 | }.bind(this), $error);
|
138 | }.bind(this));
|
139 | });
|
140 |
|
141 | (0, _ava2.default)('scope-enum with superfluous scope should succeed enum', function (t) {
|
142 | return new Promise(function ($return, $error) {
|
143 | var _scopeEnum13, _scopeEnum14, actual, expected;
|
144 |
|
145 | return Promise.resolve(parsed.superfluous).then(function ($await_7) {
|
146 | try {
|
147 | _scopeEnum13 = (0, _scopeEnum28.default)($await_7, 'always', ['bar']), _scopeEnum14 = (0, _slicedToArray3.default)(_scopeEnum13, 1), actual = _scopeEnum14[0];
|
148 |
|
149 | expected = true;
|
150 | t.deepEqual(actual, expected);
|
151 | return $return();
|
152 | } catch ($boundEx) {
|
153 | return $error($boundEx);
|
154 | }
|
155 | }.bind(this), $error);
|
156 | }.bind(this));
|
157 | });
|
158 |
|
159 | (0, _ava2.default)('scope-enum with superfluous scope and "never" should succeed', function (t) {
|
160 | return new Promise(function ($return, $error) {
|
161 | var _scopeEnum15, _scopeEnum16, actual, expected;
|
162 |
|
163 | return Promise.resolve(parsed.superfluous).then(function ($await_8) {
|
164 | try {
|
165 | _scopeEnum15 = (0, _scopeEnum28.default)($await_8, 'never', ['bar']), _scopeEnum16 = (0, _slicedToArray3.default)(_scopeEnum15, 1), actual = _scopeEnum16[0];
|
166 |
|
167 | expected = true;
|
168 | t.deepEqual(actual, expected);
|
169 | return $return();
|
170 | } catch ($boundEx) {
|
171 | return $error($boundEx);
|
172 | }
|
173 | }.bind(this), $error);
|
174 | }.bind(this));
|
175 | });
|
176 |
|
177 | (0, _ava2.default)('scope-enum with superfluous scope and always should succeed empty enum', function (t) {
|
178 | return new Promise(function ($return, $error) {
|
179 | var _scopeEnum17, _scopeEnum18, actual, expected;
|
180 |
|
181 | return Promise.resolve(parsed.superfluous).then(function ($await_9) {
|
182 | try {
|
183 | _scopeEnum17 = (0, _scopeEnum28.default)($await_9, 'always', []), _scopeEnum18 = (0, _slicedToArray3.default)(_scopeEnum17, 1), actual = _scopeEnum18[0];
|
184 |
|
185 | expected = true;
|
186 | t.deepEqual(actual, expected);
|
187 | return $return();
|
188 | } catch ($boundEx) {
|
189 | return $error($boundEx);
|
190 | }
|
191 | }.bind(this), $error);
|
192 | }.bind(this));
|
193 | });
|
194 |
|
195 | (0, _ava2.default)('scope-enum with superfluous scope and never should succeed empty enum', function (t) {
|
196 | return new Promise(function ($return, $error) {
|
197 | var _scopeEnum19, _scopeEnum20, actual, expected;
|
198 |
|
199 | return Promise.resolve(parsed.superfluous).then(function ($await_10) {
|
200 | try {
|
201 | _scopeEnum19 = (0, _scopeEnum28.default)($await_10, 'never', []), _scopeEnum20 = (0, _slicedToArray3.default)(_scopeEnum19, 1), actual = _scopeEnum20[0];
|
202 |
|
203 | expected = true;
|
204 | t.deepEqual(actual, expected);
|
205 | return $return();
|
206 | } catch ($boundEx) {
|
207 | return $error($boundEx);
|
208 | }
|
209 | }.bind(this), $error);
|
210 | }.bind(this));
|
211 | });
|
212 |
|
213 | (0, _ava2.default)('scope-enum with empty scope and always should succeed empty enum', function (t) {
|
214 | return new Promise(function ($return, $error) {
|
215 | var _scopeEnum21, _scopeEnum22, actual, expected;
|
216 |
|
217 | return Promise.resolve(parsed.superfluous).then(function ($await_11) {
|
218 | try {
|
219 | _scopeEnum21 = (0, _scopeEnum28.default)($await_11, 'always', []), _scopeEnum22 = (0, _slicedToArray3.default)(_scopeEnum21, 1), actual = _scopeEnum22[0];
|
220 |
|
221 | expected = true;
|
222 | t.deepEqual(actual, expected);
|
223 | return $return();
|
224 | } catch ($boundEx) {
|
225 | return $error($boundEx);
|
226 | }
|
227 | }.bind(this), $error);
|
228 | }.bind(this));
|
229 | });
|
230 |
|
231 | (0, _ava2.default)('scope-enum with empty scope and always should succeed filled enum', function (t) {
|
232 | return new Promise(function ($return, $error) {
|
233 | var _scopeEnum23, _scopeEnum24, actual, expected;
|
234 |
|
235 | return Promise.resolve(parsed.superfluous).then(function ($await_12) {
|
236 | try {
|
237 | _scopeEnum23 = (0, _scopeEnum28.default)($await_12, 'always', ['foo']), _scopeEnum24 = (0, _slicedToArray3.default)(_scopeEnum23, 1), actual = _scopeEnum24[0];
|
238 |
|
239 | expected = true;
|
240 | t.deepEqual(actual, expected);
|
241 | return $return();
|
242 | } catch ($boundEx) {
|
243 | return $error($boundEx);
|
244 | }
|
245 | }.bind(this), $error);
|
246 | }.bind(this));
|
247 | });
|
248 |
|
249 | (0, _ava2.default)('scope-enum with empty scope and never should succeed empty enum', function (t) {
|
250 | return new Promise(function ($return, $error) {
|
251 | var _scopeEnum25, _scopeEnum26, actual, expected;
|
252 |
|
253 | return Promise.resolve(parsed.superfluous).then(function ($await_13) {
|
254 | try {
|
255 | _scopeEnum25 = (0, _scopeEnum28.default)($await_13, 'never', []), _scopeEnum26 = (0, _slicedToArray3.default)(_scopeEnum25, 1), actual = _scopeEnum26[0];
|
256 |
|
257 | expected = true;
|
258 | t.deepEqual(actual, expected);
|
259 | return $return();
|
260 | } catch ($boundEx) {
|
261 | return $error($boundEx);
|
262 | }
|
263 | }.bind(this), $error);
|
264 | }.bind(this));
|
265 | });
|
266 |
|
\ | No newline at end of file |