Skip to content

Commit

Permalink
feat(test): refactor test runner (#52)
Browse files Browse the repository at this point in the history
* feat(test): refactor tests to use a common instance of the AddressParser

* feat(test): set $firstOnly as the default for tests
  • Loading branch information
missinglink authored Jun 12, 2019
1 parent 0d1f55a commit 7f44fe1
Show file tree
Hide file tree
Showing 19 changed files with 231 additions and 280 deletions.
7 changes: 2 additions & 5 deletions test/address.aus.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
const AddressParser = require('../parser/AddressParser')

const testcase = (test, common) => {
let parser = new AddressParser()
let assert = common.assert.bind(null, test, parser)
let assert = common.assert(test)

assert('6000, NSW, Australia', [
{ postcode: '6000' },
{ region: 'NSW' }, { country: 'Australia' }
], true)
])
}

module.exports.all = (tape, common) => {
Expand Down
11 changes: 4 additions & 7 deletions test/address.deu.test.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
const AddressParser = require('../parser/AddressParser')

const testcase = (test, common) => {
let parser = new AddressParser()
let assert = common.assert.bind(null, test, parser)
let assert = common.assert(test)

assert('Am Falkpl. 5, 10437 Berlin', [
{ street: 'Am Falkpl.' }, { housenumber: '5' },
{ postcode: '10437' }, { locality: 'Berlin' }
], true)
])

assert('Am Bürgerpark 15-18, 13156, Berlin', [
{ street: 'Am Bürgerpark' }, { housenumber: '15-18' },
{ postcode: '13156' }, { locality: 'Berlin' }
], true)
])

assert('Kaschk Bar, Linienstraße 40 10119 Berlin', [
{ place: 'Kaschk Bar' },
{ street: 'Linienstraße' }, { housenumber: '40' },
{ postcode: '10119' }, { locality: 'Berlin' }
], true)
])
}

module.exports.all = (tape, common) => {
Expand Down
7 changes: 2 additions & 5 deletions test/address.esp.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
const AddressParser = require('../parser/AddressParser')

const testcase = (test, common) => {
let parser = new AddressParser()
let assert = common.assert.bind(null, test, parser)
let assert = common.assert(test)

assert('Carrer d\'Aragó 155 08011 Barcelona', [
{ street: 'Carrer d\'Aragó' }, { housenumber: '155' },
{ postcode: '08011' }, { locality: 'Barcelona' }
], true)
])
}

module.exports.all = (tape, common) => {
Expand Down
49 changes: 23 additions & 26 deletions test/address.fra.test.js
Original file line number Diff line number Diff line change
@@ -1,96 +1,93 @@
const AddressParser = require('../parser/AddressParser')

const testcase = (test, common) => {
let parser = new AddressParser()
let assert = common.assert.bind(null, test, parser)
let assert = common.assert(test)

assert('Rue Montmartre', [
{ street: 'Rue Montmartre' }
], true)
])

assert('123 Rue Montmartre, Paris', [
{ housenumber: '123' }, { street: 'Rue Montmartre' }, { locality: 'Paris' }
], true)
])

assert('Rue de Paris', [
{ street: 'Rue de Paris' }
], true)
])

assert('Rue de la Paix', [
{ street: 'Rue de la Paix' }
], true)
])

assert('Boulevard du Général Charles De Gaulle', [
{ street: 'Boulevard du Général Charles De Gaulle' }
], true)
])

assert('11 Boulevard Saint Germains', [
{ housenumber: '11' }, { street: 'Boulevard Saint Germains' }
], true)
])

assert('Rue Saint Anne', [
{ street: 'Rue Saint Anne' }
], true)
])

assert('Boulevard Charles De Gaulle', [
{ street: 'Boulevard Charles De Gaulle' }
], true)
])

assert('Allée Victor Hugo', [
{ street: 'Allée Victor Hugo' }
], true)
])

assert('Avenue Aristide Briand', [
{ street: 'Avenue Aristide Briand' }
], true)
])

assert('Rue Henri Barbusse Paris France', [
{ street: 'Rue Henri Barbusse' }, { locality: 'Paris' }, { country: 'France' }
], true)
])

assert('Rue du Général Leclerc Dunkerque France', [
{ street: 'Rue du Général Leclerc' }, { locality: 'Dunkerque' }, { country: 'France' }
], true)
])

assert('Avenue de Sainte Rose de Lima', [
{ street: 'Avenue de Sainte Rose de Lima' }
], true)
])

assert('Rue du Capitaine Galinat Marseille France', [
{ street: 'Rue du Capitaine Galinat' }, { locality: 'Marseille' }, { country: 'France' }
], true)
])

assert('Rue Jean Baptiste Clément', [
{ street: 'Rue Jean Baptiste Clément' }
], true)
])

assert('Mery Sur Oise', [
{ locality: 'Mery Sur Oise' }
], true)
])

assert('Méry Sur Oise', [
{ locality: 'Méry Sur Oise' }
], true)
])

assert('Méry-Sur-Oise', [
{ locality: 'Méry-Sur-Oise' }
], true)
])

assert('Mery-Sur-Oise', [
{ locality: 'Mery-Sur-Oise' }
], true)
])

assert('4 Cité Du Cardinal Lemoine 75005 Paris', [
{ housenumber: '4' }, { street: 'Cité Du Cardinal Lemoine' }, { postcode: '75005' }, { locality: 'Paris' }
], true)
])

assert('32 Rue Du 4 Septembre', [
{ housenumber: '32' }, { street: 'Rue Du 4 Septembre' }
], true)
])

assert('12 Cité Roland Garros', [
{ housenumber: '12' }, { street: 'Cité Roland Garros' }
], true)
])
}

module.exports.all = (tape, common) => {
Expand Down
7 changes: 2 additions & 5 deletions test/address.gbr.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
const AddressParser = require('../parser/AddressParser')

const testcase = (test, common) => {
let parser = new AddressParser()
let assert = common.assert.bind(null, test, parser)
let assert = common.assert(test)

assert('Rushendon Furlong', [
{ street: 'Rushendon Furlong' }
], true)
])
}

module.exports.all = (tape, common) => {
Expand Down
7 changes: 2 additions & 5 deletions test/address.ind.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
const AddressParser = require('../parser/AddressParser')

const testcase = (test, common) => {
let parser = new AddressParser()
let assert = common.assert.bind(null, test, parser)
let assert = common.assert(test)

assert('100, Mahalakshmi Rd, Ganesh Nagar, Kirti Nagar, New Sanghavi, Pimpri-Chinchwad, Maharashtra 411027', [
{ housenumber: '100' }, { street: 'Mahalakshmi Rd' },
{ locality: 'Pimpri-Chinchwad' }, { region: 'Maharashtra' },
{ postcode: '411027' }
], true)
])
}

module.exports.all = (tape, common) => {
Expand Down
11 changes: 4 additions & 7 deletions test/address.nld.test.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
const AddressParser = require('../parser/AddressParser')

const testcase = (test, common) => {
let parser = new AddressParser()
let assert = common.assert.bind(null, test, parser)
let assert = common.assert(test)

assert('Julianastraat, Heel', [
{ street: 'Julianastraat' }, { locality: 'Heel' }
], true)
])

assert('Lindenlaan, Sint Odilienberg', [
{ street: 'Lindenlaan' }, { locality: 'Sint Odilienberg' }
], true)
])

assert('Bosserdijk, Hoogland', [
{ street: 'Bosserdijk' }, { locality: 'Hoogland' }
], true)
])
}

module.exports.all = (tape, common) => {
Expand Down
53 changes: 25 additions & 28 deletions test/address.nzd.test.js
Original file line number Diff line number Diff line change
@@ -1,104 +1,101 @@
const AddressParser = require('../parser/AddressParser')

const testcase = (test, common) => {
let parser = new AddressParser()
let assert = common.assert.bind(null, test, parser)
let assert = common.assert(test)

assert('21 Viaduct Harbour Avenue', [
{ housenumber: '21' }, { street: 'Viaduct Harbour Avenue' }
], true)
])

assert('30 Town Point Road', [
{ housenumber: '30' }, { street: 'Town Point Road' }
], true)
])

assert('2 Te Mako Mako Lane', [
{ housenumber: '2' }, { street: 'Te Mako Mako Lane' }
], true)
])

assert('56 Blue Ridge Drive', [
{ housenumber: '56' }, { street: 'Blue Ridge Drive' }
], true)
])

assert('14 Glen Neaves', [
{ housenumber: '14' }, { street: 'Glen Neaves' }
], true)
])

assert('516 Old Taupo Road', [
{ housenumber: '516' }, { street: 'Old Taupo Road' }
], true)
])

assert('5658 State Highway 27', [
{ housenumber: '5658' }, { street: 'State Highway 27' }
], true)
])

assert('2 Meadows Lane', [
{ housenumber: '2' }, { street: 'Meadows Lane' }
], true)
])

assert('19 Francis Drake Street', [
{ housenumber: '19' }, { street: 'Francis Drake Street' }
], true)
])

assert('115-121 Hutt Park Road', [
{ housenumber: '115-121' }, { street: 'Hutt Park Road' }
], true)
])

assert('62 Garden Road', [
{ housenumber: '62' }, { street: 'Garden Road' }
], true)
])

assert('26 Pine Hill Rise', [
{ housenumber: '26' }, { street: 'Pine Hill Rise' }
], true)
])

assert('23 Old Wharf Road', [
{ housenumber: '23' }, { street: 'Old Wharf Road' }
], true)
])

assert('183 Vista Paku', [
{ housenumber: '183' }, { street: 'Vista Paku' }
], true)
])

assert('109 Mathesons Corner Road', [
{ housenumber: '109' }, { street: 'Mathesons Corner Road' }
], true)
])

assert('81 Park Terrace', [
{ housenumber: '81' }, { street: 'Park Terrace' }
], true)
])

assert('320 Cannon Hill Crescent', [
{ housenumber: '320' }, { street: 'Cannon Hill Crescent' }
], true)
])

assert('16 The Stables', [
{ housenumber: '16' }, { street: 'The Stables' }
], true)
])

assert('35 Forbes Road', [
{ housenumber: '35' }, { street: 'Forbes Road' }
], true)
])

assert('40 O\'Shannessey Street', [
{ housenumber: '40' }, { street: 'O\'Shannessey Street' }
], true)
])

// assert('37 Hillpark Drive', [
// { housenumber: '37' }, { street: 'Hillpark Drive' }
// ], true)
// ])

// assert('260 Broadway', [
// { housenumber: '260' }, { street: 'Broadway' }
// ], true)
// ])

// assert('16 Tullamore', [
// { housenumber: '16' }, { street: 'Tullamore' }
// ], true)
// ])

assert('4207 Mountain Road', [
{ housenumber: '4207' }, { street: 'Mountain Road' }
], true)
])
}

module.exports.all = (tape, common) => {
Expand Down
Loading

0 comments on commit 7f44fe1

Please sign in to comment.