-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
test.js
39 lines (34 loc) · 1.1 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
import assert from 'node:assert/strict'
import test from 'node:test'
import {emojiEmotion} from './index.js'
test('emoji-emotion', function () {
assert.ok(Array.isArray(emojiEmotion))
assert.doesNotThrow(function () {
let index = -1
while (++index < emojiEmotion.length) {
assert.strictEqual(
typeof emojiEmotion[index].emoji,
'string',
JSON.stringify(emojiEmotion[index])
)
}
}, 'each entry should have an `emoji` string field')
assert.doesNotThrow(function () {
let index = -1
while (++index < emojiEmotion.length) {
const label = JSON.stringify(emojiEmotion[index])
assert.strictEqual(
typeof emojiEmotion[index].polarity,
'number',
'number: ' + label
)
assert.strictEqual(
Math.round(emojiEmotion[index].polarity),
emojiEmotion[index].polarity,
'integer: ' + label
)
assert.ok(emojiEmotion[index].polarity >= -5, 'gte -5: ' + label)
assert.ok(emojiEmotion[index].polarity <= 5, 'lte 5: ' + label)
}
}, 'each entry should have an `polarity` integer field')
})