-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
41 lines (32 loc) · 1022 Bytes
/
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
var test = require('tap').test
, countryCount = require('./country-count')
test('should return list with countries and nr of occurances', function (t) {
var possibleCountries = ['USA', 'Sweden', 'United States of America', 'America', 'No country', 'danish']
, countryArr = countryCount(possibleCountries)
t.deepEqual(countryArr, {
'United States': 3
, 'Sweden': 1
, 'Denmark': 1
})
t.end()
})
test('american is USA', function (t) {
t.deepEqual(countryCount([ 'American' ]), { 'United States': 1 })
t.end()
})
test('french is france', function (t) {
t.deepEqual(countryCount([ 'french' ]), { France: 1 })
t.end()
})
test('norwegian in norway', function (t) {
t.deepEqual(countryCount([ 'norwegian' ]), { Norway: 1 })
t.end()
})
test('should not parse IT, SO or AM as countries', function (t) {
var possibleCountries = ['it', 'so', 'am', 'uk']
, countryArr = countryCount(possibleCountries)
t.deepEqual(countryArr, {
'United Kingdom': 1
})
t.end()
})