-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
37 lines (31 loc) · 1.04 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
'use strict';
'use strong';
const test = require('tap').test;
const endpoint = require('endpoint');
const streetnames = require('./index.js');
test('valid zipcode', function (t) {
streetnames(2800).pipe(endpoint({ objectMode: true }, function (err, streets) {
t.ifError(err);
t.ok(streets.length > 0, 'there are streetnames in the list');
for (const name of streets) {
t.ok(typeof name === 'string', 'street name is string');
}
t.end();
}));
});
test('missing zipcode', function (t) {
streetnames(1).pipe(endpoint({ objectMode: true }, function (err, streets) {
t.ifError(err);
t.equal(streets.length, 0);
t.end();
}));
});
test('invalid zipcode', function (t) {
streetnames(10000).pipe(endpoint({ objectMode: true }, function (err, streets) {
t.equal(err.name, 'QueryParameterFormatError');
t.equal(err.message, 'One or more query parameters was ill-formed.' +
' [postnr: Value 10000 is greater than maximum 9999]');
t.equal(streets.length, 0);
t.end();
}));
});