1 | 'use strict';
|
2 |
|
3 | const assert = require('assert');
|
4 | const declineWord = require('..');
|
5 |
|
6 | const declineWrapper = (...args) => n => declineWord(n, ...args);
|
7 |
|
8 | const apples = declineWrapper('яблок', 'о', 'а');
|
9 | const plums = declineWrapper('слив', 'а', 'ы');
|
10 | const oranges = declineWrapper('апельсин', '', 'и', 'ів');
|
11 | const doors = declineWrapper('door');
|
12 | const heroes = declineWrapper('hero', '', 'es');
|
13 | const candies = declineWrapper('cand', 'y', 'ies');
|
14 | const teeth = declineWrapper('', 'tooth', 'teeth');
|
15 |
|
16 | const testCases = [
|
17 | [apples, 12, 'яблок'],
|
18 | [apples, 22, 'яблока'],
|
19 | [apples, 159, 'яблок'],
|
20 | [apples, 1151, 'яблоко'],
|
21 |
|
22 | [plums, 33, 'сливы'],
|
23 | [plums, 311, 'слив'],
|
24 | [plums, 401, 'слива'],
|
25 | [plums, 9999, 'слив'],
|
26 |
|
27 | [oranges, 1, 'апельсин'],
|
28 | [oranges, 11, 'апельсинів'],
|
29 | [oranges, 84, 'апельсини'],
|
30 | [oranges, 147, 'апельсинів'],
|
31 |
|
32 | [doors, 1, 'door'],
|
33 | [doors, 10, 'doors'],
|
34 | [doors, 11, 'doors'],
|
35 | [doors, 12, 'doors'],
|
36 | [doors, 31, 'door'],
|
37 | [doors, 101, 'door'],
|
38 |
|
39 | [heroes, 1, 'hero'],
|
40 | [heroes, 10, 'heroes'],
|
41 | [heroes, 11, 'heroes'],
|
42 | [heroes, 12, 'heroes'],
|
43 | [heroes, 31, 'hero'],
|
44 | [heroes, 101, 'hero'],
|
45 |
|
46 | [candies, 1, 'candy'],
|
47 | [candies, 10, 'candies'],
|
48 | [candies, 11, 'candies'],
|
49 | [candies, 12, 'candies'],
|
50 | [candies, 31, 'candy'],
|
51 | [candies, 101, 'candy'],
|
52 |
|
53 | [teeth, 1, 'tooth'],
|
54 | [teeth, 10, 'teeth'],
|
55 | [teeth, 11, 'teeth'],
|
56 | [teeth, 12, 'teeth'],
|
57 | [teeth, 31, 'tooth'],
|
58 | [teeth, 101, 'tooth'],
|
59 | ];
|
60 |
|
61 | describe('decline-word', () => {
|
62 | for(const [f, n, expected] of testCases) {
|
63 | it(`${n} ${expected}`, () => {
|
64 | assert.equal(f(n), expected);
|
65 | });
|
66 | }
|
67 | });
|