From bc8ee47acecf2045f9bb4a504cd8494b8a7113e9 Mon Sep 17 00:00:00 2001 From: ChinCluBi Date: Fri, 12 Aug 2016 14:21:05 +0700 Subject: move random image from lorempixel.com to unsplash.com --- test/image.unit.js | 50 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 16 deletions(-) (limited to 'test') diff --git a/test/image.unit.js b/test/image.unit.js index e7c7c3c7..a469ba87 100644 --- a/test/image.unit.js +++ b/test/image.unit.js @@ -9,17 +9,17 @@ describe("image.js", function () { it("returns a random image url from lorempixel", function () { var imageUrl = faker.image.imageUrl(); - assert.equal(imageUrl, 'http://lorempixel.com/640/480'); + assert.equal(imageUrl, 'https://source.unsplash.com/640x480'); }); it("returns a random image url from lorempixel with width and height", function () { var imageUrl = faker.image.imageUrl(100, 100); - assert.equal(imageUrl, 'http://lorempixel.com/100/100'); + assert.equal(imageUrl, 'https://source.unsplash.com/100x100'); }); 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'); + assert.equal(imageUrl, 'https://source.unsplash.com/100x100?abstract'); }); /* it.only("returns a random image url from lorempixel with a randomizer", function () { @@ -38,79 +38,97 @@ describe("image.js", function () { describe("abstract()", function () { it("returns a random abstract image url", function () { var abstract = faker.image.abstract(); - assert.equal(abstract, 'http://lorempixel.com/640/480/abstract'); + assert.equal(abstract, 'https://source.unsplash.com/640x480?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'); + assert.equal(animals, 'https://source.unsplash.com/640x480?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'); + assert.equal(business, 'https://source.unsplash.com/640x480?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'); + assert.equal(cats, 'https://source.unsplash.com/640x480?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'); + assert.equal(city, 'https://source.unsplash.com/640x480?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'); + assert.equal(food, 'https://source.unsplash.com/category/food/640x480'); }); }); 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'); + assert.equal(nightlife, 'https://source.unsplash.com/640x480?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'); + assert.equal(fashion, 'https://source.unsplash.com/640x480?fashion'); }); }); 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'); + assert.equal(people, 'https://source.unsplash.com/category/people/640x480'); }); }); 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'); + assert.equal(nature, 'https://source.unsplash.com/category/nature/640x480'); }); }); 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'); + assert.equal(sports, 'https://source.unsplash.com/640x480?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'); + assert.equal(technics, 'https://source.unsplash.com/640x480?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'); + assert.equal(transport, 'https://source.unsplash.com/640x480?transport'); + }); + }); + describe("technology()", function () { + it("returns a random technology image url", function () { + var transport = faker.image.technology(); + assert.equal(transport, 'https://source.unsplash.com/category/technology/640x480'); + }); + }); + describe("objects()", function () { + it("returns a random objects image url", function () { + var transport = faker.image.objects(); + assert.equal(transport, 'https://source.unsplash.com/category/objects/640x480'); + }); + }); + describe("buildings()", function () { + it("returns a random buildings image url", function () { + var transport = faker.image.buildings(); + assert.equal(transport, 'https://source.unsplash.com/category/buildings/640x480'); }); }); }); -- cgit v1.2.3 From 87acfc6a5c072cbf00ab02d1cf673d4db7832946 Mon Sep 17 00:00:00 2001 From: ChinCluBi Date: Tue, 27 Sep 2016 03:19:57 +0700 Subject: added lorempixel and unsplash properties to image obj --- test/image.unit.js | 270 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 159 insertions(+), 111 deletions(-) (limited to 'test') diff --git a/test/image.unit.js b/test/image.unit.js index a469ba87..d0d9a96e 100644 --- a/test/image.unit.js +++ b/test/image.unit.js @@ -5,130 +5,178 @@ if (typeof module !== 'undefined') { } describe("image.js", function () { - describe("imageUrl()", function () { + describe("lorempixel", function() { + describe("imageUrl()", function () { it("returns a random image url from lorempixel", function () { + var imageUrl = faker.image.lorempixel.imageUrl(); + + assert.equal(imageUrl, 'http://lorempixel.com/640/480'); + }); + it("returns a random image url from lorempixel with width and height", function () { + var imageUrl = faker.image.lorempixel.imageUrl(100, 100); + + assert.equal(imageUrl, 'http://lorempixel.com/100/100'); + }); + it("returns a random image url for a specified category", function () { + var imageUrl = faker.image.lorempixel.imageUrl(100, 100, 'abstract'); + + assert.equal(imageUrl, 'http://lorempixel.com/100/100/abstract'); + }); + }); + describe("avatar()", function () { + it("return a random avatar from UIFaces", function () { + assert.notEqual(-1, faker.image.lorempixel.avatar().indexOf('s3.amazonaws.com/uifaces/faces')); + }) + }); + describe("abstract()", function () { + it("returns a random abstract image url", function () { + var abstract = faker.image.lorempixel.abstract(); + assert.equal(abstract, 'http://lorempixel.com/640/480/abstract'); + }); + }); + describe("animals()", function () { + it("returns a random animals image url", function () { + var animals = faker.image.lorempixel.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.lorempixel.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.lorempixel.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.lorempixel.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.lorempixel.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.lorempixel.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.lorempixel.fashion(); + assert.equal(fashion, 'http://lorempixel.com/640/480/fashion'); + }); + }); + describe("people()", function () { + it("returns a random people image url", function () { + var people = faker.image.lorempixel.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.lorempixel.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.lorempixel.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.lorempixel.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.lorempixel.transport(); + assert.equal(transport, 'http://lorempixel.com/640/480/transport'); + }); + }); + }); + + describe("unsplash", function() { + describe("imageUrl()", function () { + it("returns a random image url from unsplash", function () { var imageUrl = faker.image.imageUrl(); assert.equal(imageUrl, 'https://source.unsplash.com/640x480'); }); - it("returns a random image url from lorempixel with width and height", function () { + it("returns a random image url from unsplash with width and height", function () { var imageUrl = faker.image.imageUrl(100, 100); assert.equal(imageUrl, 'https://source.unsplash.com/100x100'); }); it("returns a random image url for a specified category", function () { - var imageUrl = faker.image.imageUrl(100, 100, 'abstract'); + var imageUrl = faker.image.imageUrl(100, 100, 'food'); - assert.equal(imageUrl, 'https://source.unsplash.com/100x100?abstract'); + assert.equal(imageUrl, 'https://source.unsplash.com/category/food/100x100'); }); - /* - it.only("returns a random image url from lorempixel with a randomizer", function () { - var imageUrl = faker.image.imageUrl(100, 100, undefined, true); + it("returns a random image url with correct keywords for a specified category", function () { + var imageUrl = faker.image.imageUrl(100, 100, 'food', 'keyword1,keyword2'); - console.log(imageUrl); - assert.ok(imageUrl.match(/^http:\/\/lorempixel.com\/100\/100\?[\d]+$/)); - }); - */ - }); - describe("avatar()", function () { - it("return a random avatar from UIFaces", function () { - assert.notEqual(-1, faker.image.avatar().indexOf('s3.amazonaws.com/uifaces/faces')); - }) - }); - describe("abstract()", function () { - it("returns a random abstract image url", function () { - var abstract = faker.image.abstract(); - assert.equal(abstract, 'https://source.unsplash.com/640x480?abstract'); - }); - }); - describe("animals()", function () { - it("returns a random animals image url", function () { - var animals = faker.image.animals(); - assert.equal(animals, 'https://source.unsplash.com/640x480?animals'); - }); - }); - describe("business()", function () { - it("returns a random business image url", function () { - var business = faker.image.business(); - assert.equal(business, 'https://source.unsplash.com/640x480?business'); - }); - }); - describe("cats()", function () { - it("returns a random cats image url", function () { - var cats = faker.image.cats(); - assert.equal(cats, 'https://source.unsplash.com/640x480?cats'); - }); - }); - describe("city()", function () { - it("returns a random city image url", function () { - var city = faker.image.city(); - assert.equal(city, 'https://source.unsplash.com/640x480?city'); - }); - }); - describe("food()", function () { - it("returns a random food image url", function () { - var food = faker.image.food(); - assert.equal(food, 'https://source.unsplash.com/category/food/640x480'); - }); - }); - describe("nightlife()", function () { - it("returns a random nightlife image url", function () { - var nightlife = faker.image.nightlife(); - assert.equal(nightlife, 'https://source.unsplash.com/640x480?nightlife'); - }); - }); - describe("fashion()", function () { - it("returns a random fashion image url", function () { - var fashion = faker.image.fashion(); - assert.equal(fashion, 'https://source.unsplash.com/640x480?fashion'); - }); - }); - describe("people()", function () { - it("returns a random people image url", function () { - var people = faker.image.people(); - assert.equal(people, 'https://source.unsplash.com/category/people/640x480'); - }); - }); - describe("nature()", function () { - it("returns a random nature image url", function () { - var nature = faker.image.nature(); - assert.equal(nature, 'https://source.unsplash.com/category/nature/640x480'); - }); - }); - describe("sports()", function () { - it("returns a random sports image url", function () { - var sports = faker.image.sports(); - assert.equal(sports, 'https://source.unsplash.com/640x480?sports'); - }); - }); - describe("technics()", function () { - it("returns a random technics image url", function () { - var technics = faker.image.technics(); - assert.equal(technics, 'https://source.unsplash.com/640x480?technics'); - }); - }); - describe("transport()", function () { - it("returns a random transport image url", function () { - var transport = faker.image.transport(); - assert.equal(transport, 'https://source.unsplash.com/640x480?transport'); - }); - }); - describe("technology()", function () { - it("returns a random technology image url", function () { - var transport = faker.image.technology(); - assert.equal(transport, 'https://source.unsplash.com/category/technology/640x480'); - }); - }); - describe("objects()", function () { - it("returns a random objects image url", function () { - var transport = faker.image.objects(); - assert.equal(transport, 'https://source.unsplash.com/category/objects/640x480'); - }); - }); - describe("buildings()", function () { - it("returns a random buildings image url", function () { - var transport = faker.image.buildings(); - assert.equal(transport, 'https://source.unsplash.com/category/buildings/640x480'); + assert.equal(imageUrl, 'https://source.unsplash.com/category/food/100x100?keyword1,keyword2'); }); + it("returns a random image url without keyword which format is wrong for a specified category", function () { + var imageUrl = faker.image.imageUrl(100, 100, 'food', 'keyword1,?ds)0123$*908932409'); + + assert.equal(imageUrl, 'https://source.unsplash.com/category/food/100x100'); + }); + }); + describe("image()", function() { + it("returns a searching image url with keyword", function () { + var food = faker.image.image(100, 200, 'keyword1,keyword2,keyword3'); + assert.equal(food, 'https://source.unsplash.com/100x200?keyword1,keyword2,keyword3'); + }); + }) + describe("food()", function () { + it("returns a random food image url", function () { + var food = faker.image.food(); + assert.equal(food, 'https://source.unsplash.com/category/food/640x480'); + }); + }); + describe("people()", function () { + it("returns a random people image url", function () { + var people = faker.image.people(); + assert.equal(people, 'https://source.unsplash.com/category/people/640x480'); + }); + }); + describe("nature()", function () { + it("returns a random nature image url", function () { + var nature = faker.image.nature(); + assert.equal(nature, 'https://source.unsplash.com/category/nature/640x480'); + }); + }); + describe("technology()", function () { + it("returns a random technology image url", function () { + var transport = faker.image.technology(); + assert.equal(transport, 'https://source.unsplash.com/category/technology/640x480'); + }); + }); + describe("objects()", function () { + it("returns a random objects image url", function () { + var transport = faker.image.objects(); + assert.equal(transport, 'https://source.unsplash.com/category/objects/640x480'); + }); + }); + describe("buildings()", function () { + it("returns a random buildings image url", function () { + var transport = faker.image.buildings(); + assert.equal(transport, 'https://source.unsplash.com/category/buildings/640x480'); + }); + }); }); }); -- cgit v1.2.3 From 267d8f41d0a104f4613a23165a2264e87dc9594b Mon Sep 17 00:00:00 2001 From: ChinCluBi Date: Tue, 27 Sep 2016 03:27:59 +0700 Subject: remove object.assign.fix unit test --- test/image.unit.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'test') diff --git a/test/image.unit.js b/test/image.unit.js index d0d9a96e..95d18ab5 100644 --- a/test/image.unit.js +++ b/test/image.unit.js @@ -111,70 +111,70 @@ describe("image.js", function () { describe("unsplash", function() { describe("imageUrl()", function () { it("returns a random image url from unsplash", function () { - var imageUrl = faker.image.imageUrl(); + var imageUrl = faker.image.unsplash.imageUrl(); assert.equal(imageUrl, 'https://source.unsplash.com/640x480'); }); it("returns a random image url from unsplash with width and height", function () { - var imageUrl = faker.image.imageUrl(100, 100); + var imageUrl = faker.image.unsplash.imageUrl(100, 100); assert.equal(imageUrl, 'https://source.unsplash.com/100x100'); }); it("returns a random image url for a specified category", function () { - var imageUrl = faker.image.imageUrl(100, 100, 'food'); + var imageUrl = faker.image.unsplash.imageUrl(100, 100, 'food'); assert.equal(imageUrl, 'https://source.unsplash.com/category/food/100x100'); }); it("returns a random image url with correct keywords for a specified category", function () { - var imageUrl = faker.image.imageUrl(100, 100, 'food', 'keyword1,keyword2'); + var imageUrl = faker.image.unsplash.imageUrl(100, 100, 'food', 'keyword1,keyword2'); assert.equal(imageUrl, 'https://source.unsplash.com/category/food/100x100?keyword1,keyword2'); }); it("returns a random image url without keyword which format is wrong for a specified category", function () { - var imageUrl = faker.image.imageUrl(100, 100, 'food', 'keyword1,?ds)0123$*908932409'); + var imageUrl = faker.image.unsplash.imageUrl(100, 100, 'food', 'keyword1,?ds)0123$*908932409'); assert.equal(imageUrl, 'https://source.unsplash.com/category/food/100x100'); }); }); describe("image()", function() { it("returns a searching image url with keyword", function () { - var food = faker.image.image(100, 200, 'keyword1,keyword2,keyword3'); + var food = faker.image.unsplash.image(100, 200, 'keyword1,keyword2,keyword3'); assert.equal(food, 'https://source.unsplash.com/100x200?keyword1,keyword2,keyword3'); }); }) describe("food()", function () { it("returns a random food image url", function () { - var food = faker.image.food(); + var food = faker.image.unsplash.food(); assert.equal(food, 'https://source.unsplash.com/category/food/640x480'); }); }); describe("people()", function () { it("returns a random people image url", function () { - var people = faker.image.people(); + var people = faker.image.unsplash.people(); assert.equal(people, 'https://source.unsplash.com/category/people/640x480'); }); }); describe("nature()", function () { it("returns a random nature image url", function () { - var nature = faker.image.nature(); + var nature = faker.image.unsplash.nature(); assert.equal(nature, 'https://source.unsplash.com/category/nature/640x480'); }); }); describe("technology()", function () { it("returns a random technology image url", function () { - var transport = faker.image.technology(); + var transport = faker.image.unsplash.technology(); assert.equal(transport, 'https://source.unsplash.com/category/technology/640x480'); }); }); describe("objects()", function () { it("returns a random objects image url", function () { - var transport = faker.image.objects(); + var transport = faker.image.unsplash.objects(); assert.equal(transport, 'https://source.unsplash.com/category/objects/640x480'); }); }); describe("buildings()", function () { it("returns a random buildings image url", function () { - var transport = faker.image.buildings(); + var transport = faker.image.unsplash.buildings(); assert.equal(transport, 'https://source.unsplash.com/category/buildings/640x480'); }); }); -- cgit v1.2.3