Skip to content

Commit cdf5424

Browse files
committed
Testcase: search Banners
1 parent 27e7b61 commit cdf5424

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<div class="search-container">
1414
<div class="row clearfix">
1515
<div id="pagination_container"></div>
16+
<div class="banner"></div>
1617
<div class="lt search-facet-column" id="facets_container">
1718
</div>
1819
<div class="rt search-result-column">

mock/bannerResponse.json

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"searchMetaData":{
3+
"status":0,
4+
"queryTime":4,
5+
"queryParams":{
6+
"q":"men"}},
7+
"response":{"numberOfProducts":1190,"start":0,"products":[
8+
{
9+
"color":["Blue"],
10+
"productUrl":"/clothing/men/blue-exp-lion-graphic-ttoshirt/pro/2671048C/cat890006",
11+
"selling_price":[19.99],
12+
"promoMessage":"Take an Additional 30% Off Discount Taken in Cart",
13+
"category":["Men",
14+
"Clearance Men"],
15+
"styleRefinement":"Graphic Tee",
16+
"displaySalePrice":"$19.99",
17+
"title":"blue EXP lion graphic t-shirt",
18+
"sortPrice":19.99,
19+
"type":"Graphic Tee",
20+
"newProduct":"false",
21+
"productId":"2671048C",
22+
"sku":"2671048C",
23+
"description":"A sporty, double-sided graphic tee with crisp white and silver graphics. Pull on this fresh cotton crew neck with sweats or shorts and show 'em what you're made of.",
24+
"price":29.9,
25+
"catlevel3Name":"Clearance Men",
26+
"gender":["men"],
27+
"imageUrl":["http://images.express.com/is/image/expressfashion/23_267_1048_805?cache=on&wid=361&fmt=jpeg&qlt=75,1&resmode=sharp2&op_usm=1,1,5,0&defaultImage=Photo-Coming-Soon"],
28+
"uniqueId":"2671048C"},
29+
{
30+
"color":["Black"],
31+
"productUrl":"/clothing/men/nyc-freedom-graphic-tee/pro/2671024C/cat890006",
32+
"selling_price":[20.99],
33+
"category":["Men",
34+
"Clearance Men"],
35+
"styleRefinement":"Graphic Tee",
36+
"displaySalePrice":"$20.99",
37+
"title":"nyc freedom graphic tee",
38+
"sortPrice":20.99,
39+
"type":"Graphic Tee",
40+
"newProduct":"false",
41+
"productId":"2671024C",
42+
"sku":"2671024C",
43+
"description":"A go-to tee for an easy night out, this soft shirt's statement nod to the city that never sleeps is a look you can turn to season after season.",
44+
"price":29.9,
45+
"neckline":"Crew",
46+
"catlevel3Name":"Clearance Men",
47+
"ipClassStyle":["491032",
48+
"2671024",
49+
"2671024",
50+
"2671024",
51+
"2671024",
52+
"2671024"],
53+
"imageFile":"23_267_1024_058",
54+
"catlevel1Name":"Men",
55+
"gender":["men"],
56+
"imageUrl":["http://images.express.com/is/image/expressfashion/23_267_1024_058?cache=on&wid=361&fmt=jpeg&qlt=75,1&resmode=sharp2&op_usm=1,1,5,0&defaultImage=Photo-Coming-Soon"],
57+
"categorylevel2Name":"Clearance Men",
58+
"sleeveLength":"Short",
59+
"displayPrice":"$29.90",
60+
"uniqueId":"2671024C"}]
61+
},
62+
"banner":{
63+
"algo":"algo1",
64+
"categories":["men",
65+
null,
66+
null],
67+
"banners":[{
68+
"imageUrl":"https://dashboard.unbxd.com/search/users/images/logo-unbxd-black.png",
69+
"landingUrl":"https://dashboard.unbxd.com/search/",
70+
"bannerHtml":null}]},
71+
"facets":{}}

test/search/banner.spec.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
describe('Banners', function () {
2+
var expect = window.expect;
3+
fixture.setBase('mock');
4+
var bannerResponse = fixture.load('bannerResponse.json');
5+
6+
before(function(){
7+
//setup document to hold search results
8+
document.body.innerHTML = __html__['index.html'];
9+
10+
//initialize search
11+
window.searchobj = new window.Unbxd.setSearch(window.config);
12+
13+
//stub search ajax call with mock response
14+
this.stub = sinon.stub(jQuery, 'ajax').yieldsTo('success',bannerResponse);
15+
16+
});
17+
18+
after(function(){
19+
this.stub.restore();
20+
});
21+
22+
beforeEach(function(){
23+
window.searchobj.callResults(window.searchobj.paintResultSet);
24+
});
25+
26+
it('Should update the Banner landingUrl', function(){
27+
expect(jQuery(window.searchobj.options.bannerSelector + ' a').attr('href'))
28+
.to.be.equal(bannerResponse.banner.banners[0].landingUrl);
29+
});
30+
31+
it('Should update the Banner imageUrl', function(){
32+
expect(jQuery(window.searchobj.options.bannerSelector + ' img').attr('src'))
33+
.to.be.equal(bannerResponse.banner.banners[0].imageUrl);
34+
});
35+
});

0 commit comments

Comments
 (0)