diff options
| author | Marak <[email protected]> | 2021-03-22 16:31:25 -0400 |
|---|---|---|
| committer | Marak <[email protected]> | 2021-03-22 16:31:25 -0400 |
| commit | 10dd7e30cf49f03c34da1ab540df2172be40c8ea (patch) | |
| tree | a2ebc6179065775a9466a2148eb05a00fe6d23f7 /test/commerce.unit.js | |
| parent | 0b75623dac94f6062ae623fa8bbfe0e81b205d4d (diff) | |
| download | faker-10dd7e30cf49f03c34da1ab540df2172be40c8ea.tar.xz faker-10dd7e30cf49f03c34da1ab540df2172be40c8ea.zip | |
Linting fixes for `./test`
Diffstat (limited to 'test/commerce.unit.js')
| -rw-r--r-- | test/commerce.unit.js | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/test/commerce.unit.js b/test/commerce.unit.js index 61161e07..26b89a68 100644 --- a/test/commerce.unit.js +++ b/test/commerce.unit.js @@ -1,23 +1,23 @@ if (typeof module !== 'undefined') { - var assert = require('assert'), - sinon = require('sinon'), - faker = require('../index'); + var assert = require('assert'), + sinon = require('sinon'), + faker = require('../index'); } describe("commerce.js", function() { describe("color()", function() { - it("returns random value from commerce.color array", function() { - var color = faker.commerce.color(); - assert.ok(faker.definitions.commerce.color.indexOf(color) !== -1); - }); + it("returns random value from commerce.color array", function() { + var color = faker.commerce.color(); + assert.ok(faker.definitions.commerce.color.indexOf(color) !== -1); + }); }); describe("department(max, fixedValue)", function() { it("should use the default amounts when not passing arguments", function() { - var department = faker.commerce.department(); - assert.ok(department.split(" ").length === 1); + var department = faker.commerce.department(); + assert.ok(department.split(" ").length === 1); }); /* @@ -52,93 +52,93 @@ describe("commerce.js", function() { }); describe("productName()", function() { - it("returns name comprising of an adjective, material and product", function() { - sinon.spy(faker.random, 'arrayElement'); - sinon.spy(faker.commerce, 'productAdjective'); - sinon.spy(faker.commerce, 'productMaterial'); - sinon.spy(faker.commerce, 'product'); - var name = faker.commerce.productName(); - - assert.ok(name.split(' ').length >= 3); - assert.ok(faker.random.arrayElement.calledThrice); - assert.ok(faker.commerce.productAdjective.calledOnce); - assert.ok(faker.commerce.productMaterial.calledOnce); - assert.ok(faker.commerce.product.calledOnce); - - faker.random.arrayElement.restore(); - faker.commerce.productAdjective.restore(); - faker.commerce.productMaterial.restore(); - faker.commerce.product.restore(); - }); + it("returns name comprising of an adjective, material and product", function() { + sinon.spy(faker.random, 'arrayElement'); + sinon.spy(faker.commerce, 'productAdjective'); + sinon.spy(faker.commerce, 'productMaterial'); + sinon.spy(faker.commerce, 'product'); + var name = faker.commerce.productName(); + + assert.ok(name.split(' ').length >= 3); + assert.ok(faker.random.arrayElement.calledThrice); + assert.ok(faker.commerce.productAdjective.calledOnce); + assert.ok(faker.commerce.productMaterial.calledOnce); + assert.ok(faker.commerce.product.calledOnce); + + faker.random.arrayElement.restore(); + faker.commerce.productAdjective.restore(); + faker.commerce.productMaterial.restore(); + faker.commerce.product.restore(); + }); }); describe("price(min, max, dec, symbol)", function() { it("should use the default amounts when not passing arguments", function() { - var price = faker.commerce.price(); + var price = faker.commerce.price(); - assert.ok(price); - assert.strictEqual((price > 0), true, "the amount should be greater than 0"); - assert.strictEqual((price < 1001), true, "the amount should be less than 1000"); + assert.ok(price); + assert.strictEqual((price > 0), true, "the amount should be greater than 0"); + assert.strictEqual((price < 1001), true, "the amount should be less than 1000"); }); it("should use the default decimal location when not passing arguments", function() { - var price = faker.commerce.price(); + var price = faker.commerce.price(); - var decimal = "."; - var expected = price.length - 3; - var actual = price.indexOf(decimal); + var decimal = "."; + var expected = price.length - 3; + var actual = price.indexOf(decimal); - assert.strictEqual(actual, expected, "The expected location of the decimal is " + expected + " but it was " + actual + " amount " + price); + assert.strictEqual(actual, expected, "The expected location of the decimal is " + expected + " but it was " + actual + " amount " + price); }); it("should not include a currency symbol by default", function () { - var amount = faker.commerce.price(); + var amount = faker.commerce.price(); - var regexp = new RegExp(/[0-9.]/); + var regexp = new RegExp(/[0-9.]/); - var expected = true; - var actual = regexp.test(amount); + var expected = true; + var actual = regexp.test(amount); - assert.strictEqual(actual, expected, 'The expected match should not include a currency symbol'); + assert.strictEqual(actual, expected, 'The expected match should not include a currency symbol'); }); it("it should handle negative amounts, but return 0", function () { - var amount = faker.commerce.price(-200, -1); + var amount = faker.commerce.price(-200, -1); - assert.ok(amount); - assert.strictEqual((amount == 0.00), true, "the amount should equal 0"); + assert.ok(amount); + assert.strictEqual((amount == 0.00), true, "the amount should equal 0"); }); it("it should handle argument dec", function () { - var price = faker.commerce.price(100, 100, 1); + var price = faker.commerce.price(100, 100, 1); - assert.ok(price); - assert.strictEqual(price , '100.0', "the price should be equal 100.0"); + assert.ok(price); + assert.strictEqual(price , '100.0', "the price should be equal 100.0"); }); it("it should handle argument dec = 0", function () { - var price = faker.commerce.price(100, 100, 0); + var price = faker.commerce.price(100, 100, 0); - assert.ok(price); - assert.strictEqual(price , '100', "the price should be equal 100"); + assert.ok(price); + assert.strictEqual(price , '100', "the price should be equal 100"); }); }); describe("productDescription()", function() { - it("returns a random product description", function() { - sinon.spy(faker.commerce, 'productDescription'); - var description = faker.commerce.productDescription(); + it("returns a random product description", function() { + sinon.spy(faker.commerce, 'productDescription'); + var description = faker.commerce.productDescription(); - assert.ok(typeof description === 'string'); - assert.ok(faker.commerce.productDescription.calledOnce); + assert.ok(typeof description === 'string'); + assert.ok(faker.commerce.productDescription.calledOnce); - faker.commerce.productDescription.restore(); - }); - }); + faker.commerce.productDescription.restore(); + }); + }); }); |
