From 10181fbf6c1e7fa334fa0b86935326c140bee830 Mon Sep 17 00:00:00 2001 From: hkal <_@hkal.me> Date: Sat, 3 May 2014 16:46:07 -0400 Subject: functions should reference current literal: * fixes error: 'Uncaught ReferenceError: image is not defined Faker.js:275' --- lib/image.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/image.js b/lib/image.js index 76615078..22200e74 100644 --- a/lib/image.js +++ b/lib/image.js @@ -15,43 +15,43 @@ var image = { return url; }, abstractImage: function (width, height) { - return image.imageUrl(width, height, 'abstract'); + return this.imageUrl(width, height, 'abstract'); }, animals: function (width, height) { - return image.imageUrl(width, height, 'animals'); + return this.imageUrl(width, height, 'animals'); }, business: function (width, height) { - return image.imageUrl(width, height, 'business'); + return this.imageUrl(width, height, 'business'); }, cats: function (width, height) { - return image.imageUrl(width, height, 'cats'); + return this.imageUrl(width, height, 'cats'); }, city: function (width, height) { - return image.imageUrl(width, height, 'city'); + return this.imageUrl(width, height, 'city'); }, food: function (width, height) { - return image.imageUrl(width, height, 'food'); + return this.imageUrl(width, height, 'food'); }, nightlife: function (width, height) { - return image.imageUrl(width, height, 'nightlife'); + return this.imageUrl(width, height, 'nightlife'); }, fashion: function (width, height) { - return image.imageUrl(width, height, 'fashion'); + return this.imageUrl(width, height, 'fashion'); }, people: function (width, height) { - return image.imageUrl(width, height, 'people'); + return this.imageUrl(width, height, 'people'); }, nature: function (width, height) { - return image.imageUrl(width, height, 'nature'); + return this.imageUrl(width, height, 'nature'); }, sports: function (width, height) { - return image.imageUrl(width, height, 'sports'); + return this.imageUrl(width, height, 'sports'); }, technics: function (width, height) { - return image.imageUrl(width, height, 'technics'); + return this.imageUrl(width, height, 'technics'); }, transport: function (width, height) { - return image.imageUrl(width, height, 'transport'); + return this.imageUrl(width, height, 'transport'); } }; -- cgit v1.2.3 From 0cbb5997c821cbb08438b40ae372daae392625c0 Mon Sep 17 00:00:00 2001 From: hkal <_@hkal.me> Date: Sat, 3 May 2014 17:16:18 -0400 Subject: improve image test coverage --- test/image.unit.js | 88 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 79 insertions(+), 9 deletions(-) diff --git a/test/image.unit.js b/test/image.unit.js index 3d25fe9a..4fbf4fc9 100644 --- a/test/image.unit.js +++ b/test/image.unit.js @@ -16,23 +16,93 @@ describe("image.js", function () { assert.equal(imageUrl, 'http://lorempixel.com/100/100'); }); - it("returns a random image url in an abstract category", function () { + it("returns a random image url for a specified category", function () { var imageUrl = Faker.Image.imageUrl(100, 100, 'abstract'); assert.equal(imageUrl, 'http://lorempixel.com/100/100/abstract'); }); - it("returns a random image url in a category via proxy methods", function () { - var nightlife = Faker.Image.nightlife(); - assert.equal(nightlife, 'http://lorempixel.com/640/480/nightlife'); - + }); + describe("avatar()", function () { + it("return a random avatar from UIFaces", function () { + assert.notEqual(-1, Faker.Image.avatar().indexOf('s3.amazonaws.com/uifaces/faces')); + }) + }); + describe("abstractImage()", function () { + it("returns a random abstract image url", function () { + var abstract = Faker.Image.abstractImage(); + assert.equal(abstract, 'http://lorempixel.com/640/480/abstract'); + }); + }); + describe("animals()", function () { + it("returns a random animals image url", function () { + var animals = Faker.Image.animals(); + assert.equal(animals, 'http://lorempixel.com/640/480/animals'); + }); + }); + describe("business()", function () { + it("returns a random business image url", function () { + var business = Faker.Image.business(); + assert.equal(business, 'http://lorempixel.com/640/480/business'); + }); + }); + describe("cats()", function () { + it("returns a random cats image url", function () { + var cats = Faker.Image.cats(); + assert.equal(cats, 'http://lorempixel.com/640/480/cats'); + }); + }); + describe("city()", function () { + it("returns a random city image url", function () { var city = Faker.Image.city(); assert.equal(city, 'http://lorempixel.com/640/480/city'); - + }); + }); + describe("food()", function () { + it("returns a random food image url", function () { + var food = Faker.Image.food(); + assert.equal(food, 'http://lorempixel.com/640/480/food'); + }); + }); + describe("nightlife()", function () { + it("returns a random nightlife image url", function () { + var nightlife = Faker.Image.nightlife(); + assert.equal(nightlife, 'http://lorempixel.com/640/480/nightlife'); + }); + }); + describe("fashion()", function () { + it("returns a random fashion image url", function () { var fashion = Faker.Image.fashion(); assert.equal(fashion, 'http://lorempixel.com/640/480/fashion'); }); - it("return a random avatar from UIFaces", function () { - assert.notEqual(-1, Faker.Image.avatar().indexOf('s3.amazonaws.com/uifaces/faces')); - }) + }); + describe("people()", function () { + it("returns a random people image url", function () { + var people = Faker.Image.people(); + assert.equal(people, 'http://lorempixel.com/640/480/people'); + }); + }); + describe("nature()", function () { + it("returns a random nature image url", function () { + var nature = Faker.Image.nature(); + assert.equal(nature, 'http://lorempixel.com/640/480/nature'); + }); + }); + describe("sports()", function () { + it("returns a random sports image url", function () { + var sports = Faker.Image.sports(); + assert.equal(sports, 'http://lorempixel.com/640/480/sports'); + }); + }); + describe("technics()", function () { + it("returns a random technics image url", function () { + var technics = Faker.Image.technics(); + assert.equal(technics, 'http://lorempixel.com/640/480/technics'); + }); + }); + describe("transport()", function () { + it("returns a random transport image url", function () { + var transport = Faker.Image.transport(); + assert.equal(transport, 'http://lorempixel.com/640/480/transport'); + }); }); }); -- cgit v1.2.3