inflections-test.js
3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
(function() {
var assert, vows;
vows = require('vows');
assert = require('assert');
vows.describe('Module Inflector inflections').addBatch({
'Test inflector inflections': {
topic: require('../../lib/inflections'),
'clear': {
'single': function(topic) {
topic.uncountables = [1, 2, 3];
topic.humans = [1, 2, 3];
topic.clear('uncountables');
assert.isEmpty(topic.uncountables);
return assert.deepEqual(topic.humans, [1, 2, 3]);
},
'all': function(topic) {
assert.deepEqual(topic.humans, [1, 2, 3]);
topic.uncountables = [1, 2, 3];
topic.clear();
assert.isEmpty(topic.uncountables);
return assert.isEmpty(topic.humans);
}
},
'uncountable': {
'one item': function(topic) {
topic.clear();
assert.isEmpty(topic.uncountables);
topic.uncountable('money');
return assert.deepEqual(topic.uncountables, ['money']);
},
'many items': function(topic) {
topic.clear();
assert.isEmpty(topic.uncountables);
topic.uncountable(['money', 'rice']);
return assert.deepEqual(topic.uncountables, ['money', 'rice']);
}
},
'human': function(topic) {
topic.clear();
assert.isEmpty(topic.humans);
topic.human("legacy_col_person_name", "Name");
return assert.deepEqual(topic.humans, [["legacy_col_person_name", "Name"]]);
},
'plural': function(topic) {
topic.clear();
assert.isEmpty(topic.plurals);
topic.plural('ox', 'oxen');
assert.deepEqual(topic.plurals, [['ox', 'oxen']]);
topic.uncountable('money');
assert.deepEqual(topic.uncountables, ['money']);
topic.uncountable('monies');
topic.plural('money', 'monies');
assert.deepEqual(topic.plurals, [['money', 'monies'], ['ox', 'oxen']]);
return assert.isEmpty(topic.uncountables);
},
'singular': function(topic) {
topic.clear();
assert.isEmpty(topic.singulars);
topic.singular('ox', 'oxen');
assert.deepEqual(topic.singulars, [['ox', 'oxen']]);
topic.uncountable('money');
assert.deepEqual(topic.uncountables, ['money']);
topic.uncountable('monies');
topic.singular('money', 'monies');
assert.deepEqual(topic.singulars, [['money', 'monies'], ['ox', 'oxen']]);
return assert.isEmpty(topic.uncountables);
},
'irregular': function(topic) {
topic.clear();
topic.uncountable(['octopi', 'octopus']);
assert.deepEqual(topic.uncountables, ['octopi', 'octopus']);
topic.irregular('octopus', 'octopi');
assert.isEmpty(topic.uncountables);
assert.equal(topic.singulars[0][0].toString(), /(o)ctopi$/i.toString());
assert.equal(topic.singulars[0][1], '$1ctopus');
assert.equal(topic.plurals[0][0].toString(), /(o)ctopi$/i.toString());
assert.equal(topic.plurals[0][1], '$1ctopi');
assert.equal(topic.plurals[1][0].toString(), /(o)ctopus$/i.toString());
return assert.equal(topic.plurals[1][1].toString(), '$1ctopi');
}
}
})["export"](module);
}).call(this);