-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
43 lines (38 loc) · 1.45 KB
/
test.js
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
var idioms = require('./index');
var assert = require('assert');
function isNonEmptyString(str) {
return typeof str === "string"; //&& str.length > 0;
}
describe("Idioms", function () {
var foundIdioms = {};
idioms.forEach(function (idiom) {
var idiomString = idiom.idiom;
var meaningString = idiom.meaning;
describe(idiom.idiom, function () {
describe('idiom', function () {
it("should be non-empty string", function () {
assert(isNonEmptyString(idiom.idiom), "Expected a non-empty string");
});
it("should be trimmed", function () {
var actual = `'${idiom.idiom}'`;
var expected = `'${idiom.idiom.trim()}'`;
assert.equal(actual, expected, "Expected idiom to already be trimmed");
});
it("idiom is unique in array", function () {
assert(foundIdioms[idiomString] === undefined, `Idiom (${idiomString}) already exists in array`);
foundIdioms[idiomString] = idiomString;
});
});
describe('meaning', function () {
it("should be non-empty string", function () {
assert(isNonEmptyString(idiom.meaning), "Expected a non-empty string");
});
it("should be trimmed", function () {
var actual = `'${idiom.meaning}'`;
var expected = `'${idiom.meaning.trim()}'`;
assert.equal(actual, expected, "Expected meaning to already be trimmed");
});
});
});
});
});