Skip to content

Commit 73bfdd4

Browse files
committed
Testcase: search Zero Results
1 parent 31dc373 commit 73bfdd4

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

mock/zeroResult.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"searchMetaData":{
3+
"status":0,
4+
"queryTime":2,
5+
"queryParams":{
6+
"q":"sadasdsd"}},
7+
"response":{"numberOfProducts":0,"start":0,"products":[]
8+
},
9+
"facets":{
10+
"infield1_fq":{
11+
"type":"facet_fields",
12+
"values":[]},
13+
"infield2_fq":{
14+
"type":"facet_fields",
15+
"values":[]},
16+
"infield3_fq":{
17+
"type":"facet_fields",
18+
"values":[]},
19+
"infield4_fq":{
20+
"type":"facet_fields",
21+
"values":[]},
22+
"gender_fq":{
23+
"type":"facet_fields",
24+
"values":[]},
25+
"size_fq":{
26+
"type":"facet_fields",
27+
"values":[]},
28+
"type_fq":{
29+
"type":"facet_fields",
30+
"values":[]},
31+
"fit_fq":{
32+
"type":"facet_fields",
33+
"values":[]},
34+
"Color_fq":{
35+
"type":"facet_fields",
36+
"values":[]},
37+
"Availability_fq":{
38+
"type":"facet_fields",
39+
"values":[]},
40+
"price_fq":{
41+
"type":"facet_ranges",
42+
"values":{
43+
"counts":[],
44+
"gap":30.0,
45+
"start":0.0,
46+
"end":210.0}}}}

test/search/noResult.spec.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
describe('No results', function () {
2+
var expect = window.expect;
3+
before(function(){
4+
fixture.setBase('mock');
5+
var zeroResultTest = fixture.load('zeroResult.json');
6+
//setup document to hold search results
7+
document.body.innerHTML = __html__['index.html'];
8+
9+
//initialize search
10+
window.searchobj = new window.Unbxd.setSearch(window.config);
11+
12+
//stub search ajax call with mock response
13+
this.stub = sinon.stub(jQuery, 'ajax').yieldsTo('success',zeroResultTest);
14+
15+
this.spyOnIntialResultLoad = sinon.spy(window.searchobj.options,
16+
'onIntialResultLoad');
17+
this.spyOnNoResult = sinon.spy(window.searchobj.options,'onNoResult');
18+
window.searchobj.callResults(window.searchobj.paintResultSet);
19+
});
20+
21+
after(function(){
22+
this.stub.restore();
23+
});
24+
25+
it('Should call onNoResult',function(){
26+
expect(this.spyOnNoResult.called).to.equal(true);
27+
});
28+
29+
it('Should not call OnIntialResultLoad',function(){
30+
expect(this.spyOnIntialResultLoad.called).to.equal(false);
31+
});
32+
});

0 commit comments

Comments
 (0)