forked from pelias/schema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyzer_peliasZip.js
52 lines (39 loc) · 1.74 KB
/
analyzer_peliasZip.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
// validate analyzer is behaving as expected
var tape = require('tape'),
Suite = require('../test/elastictest/Suite'),
punctuation = require('../punctuation');
module.exports.tests = {};
module.exports.tests.analyze = function(test, common){
test( 'analyze', function(t){
var suite = new Suite( common.clientOpts, common.create );
var assertAnalysis = common.analyze.bind( null, suite, t, 'peliasZip' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up
assertAnalysis( 'lowercase', 'F', ['f']);
assertAnalysis( 'trim', ' f ', ['f'] );
assertAnalysis( 'alphanumeric', 'a-f g', ['afg'] );
suite.run( t.end );
});
};
module.exports.tests.functional = function(test, common){
test( 'functional', function(t){
var suite = new Suite( common.clientOpts, common.create );
var assertAnalysis = common.analyze.bind( null, suite, t, 'peliasZip' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up
assertAnalysis( 'usa zip', '10010', [ '10010' ]);
assertAnalysis( 'usa zip', 10010, [ '10010' ]);
assertAnalysis( 'usa zip - punctuation', '10-010', [ '10010' ]);
assertAnalysis( 'usa zip - whitespace', '10 010', [ '10010' ]);
assertAnalysis( 'uk postcode', 'E24DN', [ 'e24dn' ]);
assertAnalysis( 'uk postcode - punctuation', 'E2-4DN', [ 'e24dn' ]);
assertAnalysis( 'uk postcode - whitespace', 'E 24 DN', [ 'e24dn' ]);
suite.run( t.end );
});
};
module.exports.all = function (tape, common) {
function test(name, testFunction) {
return tape('peliasZip: ' + name, testFunction);
}
for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};