forked from wooorm/gemoji
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
67 lines (57 loc) · 1.69 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'use strict'
var test = require('tape')
var emoji = require('./emoji.json')
var gemoji = require('.')
test('gemoji', function(t) {
t.ok('name' in gemoji, 'should have a `name` property')
t.ok('unicode' in gemoji, 'should have an `unicode` property')
t.end()
})
emoji.forEach(describeEntry)
// Validate if a crawled gemoji is indeed (correctly) present in this module.
function describeEntry(entry) {
var unicode = entry.emoji
var description
var aliases
var tags
var alias
var information
var category
// Some gemoji, such as `octocat`, do not have a unicode representation.
// Those are not present in `gemoji`.
// Exit.
if (!unicode) {
return
}
description = entry.description
aliases = entry.aliases
tags = entry.tags
alias = aliases[0]
information = gemoji.unicode[unicode]
category = entry.category.toLowerCase()
test(unicode + ' ' + description, function(t) {
aliases.forEach(function(name) {
t.equal(
gemoji.name[name].emoji,
unicode,
'should be accessible by name (' + name + ' > object)'
)
})
t.equal(
gemoji.unicode[unicode].name,
alias,
'should be accessible by emoji (' + unicode + ' > object)'
)
t.equal(information.name, alias, 'should have a `name` field')
t.equal(information.emoji, unicode, 'should have an `emoji` field')
t.equal(information.category, category, 'should have a `category` field')
t.equal(
information.description,
description,
'should have a `description` field'
)
t.deepEqual(information.names, aliases, 'should have a `names` field')
t.deepEqual(information.tags, tags, 'should have a `tags` field')
t.end()
})
}