-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
66 lines (53 loc) · 2.07 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
var assert = require('assert'),
chai = require('chai'),
expect = chai.expect,
soundex = require('./index.js')
describe('Encoding with default', function(){
it('encode single strings', function(){
expect(soundex('Washington')).to.equal('W252')
expect(soundex('Wu')).to.equal('W000')
expect(soundex('DeSmet')).to.equal('D253')
expect(soundex('Gutierrez')).to.equal('G362')
expect(soundex('Pfister')).to.equal('P236')
expect(soundex('Jackson')).to.equal('J250')
expect(soundex('Tymczak')).to.equal('T522')
expect(soundex('Ashcraft')).to.equal('A261')
expect(soundex('Euler')).to.equal('E460')
expect(soundex('Gauss')).to.equal('G200')
expect(soundex('Hilbert')).to.equal('H416')
expect(soundex('Knuth')).to.equal('K530')
expect(soundex('Lloyd')).to.equal('L300')
expect(soundex('Lukasiewicz')).to.equal('L222')
expect(soundex('Battlestar')).to.equal('B342')
})
})
describe('Encoding with default', function(){
it('encode single strings', function(){
var opts = {
zeroed: false
}
expect(soundex('Wu', opts)).to.equal('W')
expect(soundex('Jackson', opts)).to.equal('J25')
expect(soundex('Euler', opts)).to.equal('E46')
expect(soundex('Gauss', opts)).to.equal('G2')
expect(soundex('Knuth', opts)).to.equal('K53')
expect(soundex('Lloyd', opts)).to.equal('L3')
})
})
// These strings are compared to the ones I generated from SELECT SOUNDEX(str); in MySQL 5.6.12
describe('Encoding with mysql', function(){
it('encode single strings', function(){
var opts = {
mysql: true
}
expect(soundex('Washington', opts)).to.equal('W25235')
expect(soundex('Wu', opts)).to.equal('W000')
expect(soundex('DeSmet', opts)).to.equal('D253')
expect(soundex('Gutierrez', opts)).to.equal('G362')
expect(soundex('Pfister', opts)).to.equal('P236')
expect(soundex('Jackson', opts)).to.equal('J500')
expect(soundex('Tymczak', opts)).to.equal('T520')
expect(soundex('Ashcraft', opts)).to.equal('A2613')
expect(soundex('Battlestar', opts)).to.equal('B34236')
})
})