Skip to content

Commit 6336c3f

Browse files
committed
Testcase: search Initialize
1 parent bedb053 commit 6336c3f

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

mock/searchTestResponse.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"searchMetaData":{"status":0,"queryTime":1,"queryParams":{"facet.multiselect":"true","q":"*","indent":"off","start":"0","rows":"12","fields":"image_url,title,brand,price,uniqueId","wt":"json"}},"response":{"numberOfProducts":50,"start":0,"products":[{"title":"Bates Lites High Gloss Oxford Military Dress Shoes 942 (Black)","uniqueId":"3870","brand":"Bates Boots","price":124.95},{"title":"Bates DuraShocks Women's Lightweight USMC Boots E57501 (Tan)","uniqueId":"3867","brand":"Bates Boots","price":199.95},{"title":"Bates DuraShocks USMC Lightweight Boots E50501 (Tan)","uniqueId":"3868","brand":"Bates Boots","price":199.95},{"title":"Bates DuraShocks USMC Steel Toe Hot Weather Boots E40501 (Tan)","uniqueId":"3869","brand":"Bates Boots","price":219.95},{"title":"Bates Lites Leather Oxford Military and Police Dress Shoes E00932 (Black)","uniqueId":"3871","brand":"Bates Boots","price":139.95},{"title":"Bates GX-8 Gore-Tex Waterproof Side Zip Boots E02268 (Black)","uniqueId":"3872","brand":"Bates Boots","price":154.95},{"title":"Bates GX-8 Gore-Tex Non Metallic Safety Toe 8 inch Boot (Black)","uniqueId":"3873","brand":"Bates Boots","price":179.95},{"title":"Bates GX-8 Composite Toe Side Zipper Boots (Desert Tan)","uniqueId":"3874","brand":"Bates Boots","price":139.95},{"title":"Belleville F790 Women's Waterproof Combat and Flight Boot (Desert Tan)","uniqueId":"3876","brand":"Belleville Boots","price":165.99},{"title":"Belleville F650ST Women's Waterproof Safety Toe Boots (Sage)","uniqueId":"3877","brand":"Belleville Boots","price":178.99},{"title":"Belleville 600 Hot Weather USAF Boot (Sage)","uniqueId":"3878","brand":"Belleville Boots","price":130.99},{"title":"Belleville 650ST Waterproof Goretex Safety Toe Boot (Sage)","uniqueId":"3879","brand":"Belleville Boots","price":176.99}]},"facets":{"color_fq":{"type":"facet_fields","values":["Black",645,"",345,"ABU",259,"ACU",215,"Multicam",213]}}}

test/search/init.spec.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
describe('On Init', function () {
2+
var expect = window.expect;
3+
before(function(){
4+
fixture.setBase('mock');
5+
var searchTest = fixture.load('searchTestResponse.json');
6+
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',searchTest);
15+
16+
//spy OnIntialResultLoad, OnFacetLoad, OnPageLoad and OnNoResult
17+
this.spyOnIntialResultLoad = sinon.spy(window.searchobj.options,
18+
'onIntialResultLoad');
19+
this.spyOnFacetLoad = sinon.spy(window.searchobj.options, 'onFacetLoad');
20+
this.spyOnPageLoad = sinon.spy(window.searchobj.options, 'onPageLoad');
21+
this.spyOnNoResult = sinon.spy(window.searchobj.options, 'onNoResult');
22+
23+
window.searchobj.callResults(window.searchobj.paintResultSet);
24+
});
25+
26+
after(function(){
27+
this.stub.restore();
28+
});
29+
30+
it('Should call onIntialResultLoad', function(){
31+
expect(this.spyOnIntialResultLoad.called).to.equal(true);
32+
});
33+
34+
it('Should call onFacetLoad', function(){
35+
expect(this.spyOnFacetLoad.called).to.equal(true);
36+
});
37+
38+
it('Should not call onPageLoad', function(){
39+
expect(this.spyOnPageLoad.called).to.equal(false);
40+
});
41+
42+
it('Should not call onNoResult', function(){
43+
expect(this.spyOnNoResult.called).to.equal(false);
44+
});
45+
});

0 commit comments

Comments
 (0)