diff options
| author | Matthew Bergman <[email protected]> | 2014-05-05 00:37:46 -0400 |
|---|---|---|
| committer | Matthew Bergman <[email protected]> | 2014-05-05 00:37:46 -0400 |
| commit | 2a089036b7f231cd6e1d4635cc13d54685c8758e (patch) | |
| tree | f3ed031127da548ddbf8ad20ab463780e87c79e6 | |
| parent | 4cd2837454068fff8193ed0db9d73cb20b3f0fb5 (diff) | |
| parent | 0cbb5997c821cbb08438b40ae372daae392625c0 (diff) | |
| download | faker-2a089036b7f231cd6e1d4635cc13d54685c8758e.tar.xz faker-2a089036b7f231cd6e1d4635cc13d54685c8758e.zip | |
Merge pull request #79 from hkal/resolve_image_undefined
Resolve image undefined
| -rw-r--r-- | lib/image.js | 26 | ||||
| -rw-r--r-- | test/image.unit.js | 88 |
2 files changed, 92 insertions, 22 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'); } }; 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'); + }); }); }); |
