diff options
| author | Marak <[email protected]> | 2018-10-27 12:32:45 -0400 |
|---|---|---|
| committer | Marak <[email protected]> | 2018-10-27 12:32:45 -0400 |
| commit | 3f7ff55e341447eecc90676ce56681f05d84d7f3 (patch) | |
| tree | 141c03a97a9ae43be23cab0804d6f6260298d08c | |
| parent | 8f032d2520f83b5e68b86cecc22dfb4a0cacee2b (diff) | |
| download | faker-3f7ff55e341447eecc90676ce56681f05d84d7f3.tar.xz faker-3f7ff55e341447eecc90676ce56681f05d84d7f3.zip | |
[test] [minor] Improving test coverage
| -rw-r--r-- | test/address.unit.js | 37 | ||||
| -rw-r--r-- | test/name.unit.js | 7 |
2 files changed, 42 insertions, 2 deletions
diff --git a/test/address.unit.js b/test/address.unit.js index 0d691742..d63cb78c 100644 --- a/test/address.unit.js +++ b/test/address.unit.js @@ -381,13 +381,26 @@ describe("address.js", function () { faker.address.direction.restore(); }) - it("returns abbreviation when useAbbr is true", function () { + it("returns abbreviation when useAbbr is false", function () { sinon.stub(faker.address, 'direction').returns('N'); + var direction = faker.address.direction(false); + assert.equal(direction, 'N'); + faker.address.direction.restore(); + }) + + it("returns abbreviation when useAbbr is true", function () { var direction = faker.address.direction(true); + assert.equal(typeof direction, 'string'); + assert.equal(direction.length <= 2, true); + }) + it("returns abbreviation when useAbbr is true", function () { + sinon.stub(faker.address, 'direction').returns('N'); + var direction = faker.address.direction(true); assert.equal(direction, 'N'); faker.address.direction.restore(); }) + }) describe("ordinalDirection()", function () { @@ -406,6 +419,14 @@ describe("address.js", function () { assert.equal(ordinalDirection, 'W'); faker.address.ordinalDirection.restore(); }) + + it("returns abbreviation when useAbbr is true", function () { + var ordinalDirection = faker.address.ordinalDirection(true); + assert.equal(typeof ordinalDirection, 'string'); + assert.equal(ordinalDirection.length <= 2, true); + }) + + }) describe("cardinalDirection()", function () { @@ -424,6 +445,13 @@ describe("address.js", function () { assert.equal(cardinalDirection, 'NW'); faker.address.cardinalDirection.restore(); }) + + it("returns abbreviation when useAbbr is true", function () { + var cardinalDirection = faker.address.cardinalDirection(true); + assert.equal(typeof cardinalDirection, 'string'); + assert.equal(cardinalDirection.length <= 2, true); + }) + }) describe("nearbyGPSCoordinate()", function () { @@ -471,6 +499,13 @@ describe("address.js", function () { var actualDistance = haversine(latFloat1, lonFloat1, latFloat2, lonFloat2, isMetric); assert.ok(actualDistance <= (radius + error)); } + + // test once with undefined radius + var coordinate = faker.address.nearbyGPSCoordinate([latFloat1, lonFloat1], undefined, isMetric); + assert.ok(coordinate.length === 2); + assert.ok(typeof coordinate[0] === 'string'); + assert.ok(typeof coordinate[1] === 'string'); + }); }); diff --git a/test/name.unit.js b/test/name.unit.js index 679f1202..d6b311a3 100644 --- a/test/name.unit.js +++ b/test/name.unit.js @@ -163,7 +163,6 @@ describe("name.js", function () { it("returns male prefix", function () { var prefix = faker.name.prefix(0); - assert.equal(prefix, 'Mp') }); @@ -172,6 +171,12 @@ describe("name.js", function () { assert.equal(prefix, 'Fp'); }); + + it("returns either prefix", function () { + var prefix = faker.name.prefix(); + assert(['Mp', 'Fp'].indexOf(prefix) >= 0) + }); + }); describe('when using a locale without gender specific name prefixes', function () { |
