Skip to content

Commit

Permalink
v2.5.0 - overhauled testing framework
Browse files Browse the repository at this point in the history
  • Loading branch information
Justintime50 committed Oct 21, 2020
1 parent 90a7d72 commit edee3dd
Show file tree
Hide file tree
Showing 14 changed files with 394 additions and 182 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# CHANGELOG

## v2.4.1 (2020-10-21)
## v2.5.0 (2020-10-21)

* More verbose testing by iterating each address record to test against instead of just index 0
* Overhauled testing framework
* Introduced `chai` for better `assert` and `expect`
* Went from ~50 tests to ~1700 tests by iterating each record
* Added tests to ensure the data structure of each record was uniform by asserting keys were the same across every record - corrected a few records with bad keys

## v2.4.0 (2020-10-21)

Expand Down
2 changes: 1 addition & 1 deletion data/us-west/ca-addresses-slim.min.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/us-west/nv-addresses-slim.min.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/us-west/or-addresses-slim.min.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/us-west/ut-addresses-slim.min.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/us-west/wa-addresses-slim.min.json

Large diffs are not rendered by default.

55 changes: 54 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dad-tool",
"version": "2.4.1",
"version": "2.5.0",
"description": "Dummy Address Data (DAD) allows you to query a massive dataset for real addresses that are perfect for dummy data.",
"main": "index.js",
"scripts": {
Expand All @@ -24,6 +24,7 @@
"dad": "./index.js"
},
"devDependencies": {
"chai": "^4.2.0",
"coveralls": "^3.1.0",
"eslint": "^6.8.0",
"mocha": "^8.1.1",
Expand Down
36 changes: 23 additions & 13 deletions test/australia-data.test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
/* eslint-env node, mocha */
const assert = require('assert');
const assert = require('chai').assert
const expect = require('chai').expect
const dad = require('../index')

describe('Australia Data', () => {
it('returns a VT address', () => {
const address = dad.random('AU_VT')
assert.strictEqual(address.state, 'VIC');
describe('AU VT Address Data', function () {
const address = dad.random('AU_VT')
const addresses = dad.list('AU_VT')

it('returns a random VT address', function () {
assert.equal(address.state, 'VIC');
});

it('returns a list of VT addresses', () => {
const addresses = dad.list('AU_VT')
assert.strictEqual(addresses.addresses.length, 5);
var i
while (i <= addresses.length) {
assert.strictEqual(addresses.addresses[i].state, 'VIC')
}
it('returns a list of VT addresses with a length of 5', function () {
assert.equal(addresses.addresses.length, 5);
})

addresses.addresses.forEach(function (singleAddress) {
it(`returns "${singleAddress.street1}" from a list of VT addresses`, function () {
assert.equal(singleAddress.state, 'VIC')
});
})

addresses.addresses.forEach(function (singleAddress) {
it(`ensures the data structure of "${singleAddress.street1}" is uniform`, function () {
expect(singleAddress).to.contain.all.keys('street1', 'street2', 'city', 'state', 'zip', 'country');
});
});
});
})
36 changes: 23 additions & 13 deletions test/canada-data.test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
/* eslint-env node, mocha */
const assert = require('assert');
const assert = require('chai').assert
const expect = require('chai').expect
const dad = require('../index')

describe('Canada Data', () => {
it('returns a BC address', () => {
const address = dad.random('CA_BC')
assert.strictEqual(address.state, 'BC');
describe('CA BC Address Data', function () {
const address = dad.random('CA_BC')
const addresses = dad.list('CA_BC')

it('returns a random BC address', function () {
assert.equal(address.state, 'BC');
});

it('returns a list of BC addresses', () => {
const addresses = dad.list('CA_BC')
assert.strictEqual(addresses.addresses.length, 5);
var i
while (i <= addresses.length) {
assert.strictEqual(addresses.addresses[i].state, 'BC')
}
it('returns a list of BC addresses with a length of 5', function () {
assert.equal(addresses.addresses.length, 5);
})

addresses.addresses.forEach(function (singleAddress) {
it(`returns "${singleAddress.street1}" from a list of BC addresses`, function () {
assert.equal(singleAddress.state, 'BC')
});
})

addresses.addresses.forEach(function (singleAddress) {
it(`ensures the data structure of "${singleAddress.street1}" is uniform`, function () {
expect(singleAddress).to.contain.all.keys('street1', 'street2', 'city', 'state', 'zip', 'country');
});
});
});
})
67 changes: 44 additions & 23 deletions test/china-data.test.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,54 @@
/* eslint-env node, mocha */
const assert = require('assert');
const assert = require('chai').assert
const expect = require('chai').expect
const dad = require('../index')

describe('China Data', () => {
it('returns a BJ address', () => {
const address = dad.random('CN_BJ')
assert.strictEqual(address.country, 'CN');
describe('CN BJ Address Data', function () {
const address = dad.random('CN_BJ')
const addresses = dad.list('CN_BJ')

it('returns a random BJ address', function () {
assert.equal(address.country, 'CN');
});

it('returns a list of BJ addresses', () => {
const addresses = dad.list('CN_BJ')
assert.strictEqual(addresses.addresses.length, 5);
var i
while (i <= addresses.length) {
assert.strictEqual(addresses.addresses[i].country, 'CN')
}
it('returns a list of BJ addresses with a length of 5', function () {
assert.equal(addresses.addresses.length, 5);
})

addresses.addresses.forEach(function (singleAddress) {
it(`returns "${singleAddress.street1}" from a list of BJ addresses`, function () {
assert.equal(singleAddress.country, 'CN')
});
})

addresses.addresses.forEach(function (singleAddress) {
it(`ensures the data structure of "${singleAddress.street1}" is uniform`, function () {
expect(singleAddress).to.contain.all.keys('street1', 'street2', 'city', 'state', 'zip', 'country');
});
});
})

it('returns a HK address', () => {
const address = dad.random('CN_HK')
assert.strictEqual(address.state, 'Hong Kong');
describe('CN HK Address Data', function () {
const address = dad.random('CN_HK')
const addresses = dad.list('CN_HK')

it('returns a random HK address', function () {
assert.equal(address.state, 'Hong Kong');
});

it('returns a list of HK addresses', () => {
const addresses = dad.list('CN_HK')
assert.strictEqual(addresses.addresses.length, 5);
var i
while (i <= addresses.length) {
assert.strictEqual(addresses.addresses[i].state, 'Hong Kong')
}
it('returns a list of HK addresses with a length of 5', function () {
assert.equal(addresses.addresses.length, 5);
})

addresses.addresses.forEach(function (singleAddress) {
it(`returns "${singleAddress.street1}" from a list of HK addresses`, function () {
assert.equal(singleAddress.state, 'Hong Kong')
});
})

addresses.addresses.forEach(function (singleAddress) {
it(`ensures the data structure of "${singleAddress.street1}" is uniform`, function () {
expect(singleAddress).to.contain.all.keys('street1', 'street2', 'city', 'state', 'zip', 'country');
});
});
});
})
8 changes: 4 additions & 4 deletions test/errors.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* eslint-env node, mocha */
const assert = require('assert');
const assert = require('chai').assert
const dad = require('../index')

describe('Bad Data', () => {
it('returns an error when bad data is passed', () => {
describe('Bad Data', function () {
it('returns an error when bad data is passed', function () {
assert.throws(() => { dad.random('BAD_DATA') }, Error);
});

it('returns an error when no data is passed', () => {
it('returns an error when no data is passed', function () {
assert.throws(() => { dad.random() }, Error);
});
});
Loading

0 comments on commit edee3dd

Please sign in to comment.