Skip to content

Commit 31dc373

Browse files
committed
Testcase: search Spellcheck
1 parent 6336c3f commit 31dc373

File tree

4 files changed

+170
-0
lines changed

4 files changed

+170
-0
lines changed

mock/spellCheckWithResults.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"searchMetaData":{
3+
"status":0,
4+
"queryTime":6,
5+
"queryParams":{
6+
"q":"shart"}},
7+
"response":{"numberOfProducts":10,"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}]
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}}},
47+
"didYouMean":[{
48+
"suggestion":"shirt",
49+
"frequency":"344"}]}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"searchMetaData":{
3+
"status":0,
4+
"queryTime":6,
5+
"queryParams":{
6+
"q":"shart"}},
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}}},
47+
"didYouMean":[{
48+
"suggestion":"shirt",
49+
"frequency":"344"}]}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
describe('SpellCheck - with results', function () {
2+
var expect = window.expect;
3+
var spellCheckTest;
4+
5+
before(function(){
6+
7+
fixture.setBase('mock');
8+
spellCheckTest = fixture.load('spellCheckWithResults.json');
9+
//setup document to hold search results
10+
document.body.innerHTML = __html__['index.html'];
11+
12+
//initialize search
13+
window.searchobj = new window.Unbxd.setSearch(window.config);
14+
15+
//stub search ajax call with mock response
16+
this.stub = sinon.stub(jQuery, 'ajax').yieldsTo('success', spellCheckTest);
17+
window.searchobj.callResults(window.searchobj.paintResultSet);
18+
});
19+
20+
after(function(){
21+
this.stub.restore();
22+
});
23+
24+
it('Should display didYouMean', function(){
25+
expect(jQuery(window.searchobj.options.spellCheck).text())
26+
.to.equal('Did you mean : '+ spellCheckTest.didYouMean[0].suggestion +' ?');
27+
});
28+
29+
it('Should load actual query results',function(){
30+
expect(window.searchobj.params.query)
31+
.to.equal(spellCheckTest.searchMetaData.queryParams.q);
32+
});
33+
});
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
describe('SpellCheck - Zero results', function () {
2+
var expect = window.expect;
3+
var spellCheckTest;
4+
var searchTest;
5+
6+
before(function(){
7+
8+
fixture.setBase('mock');
9+
spellCheckTest = fixture.load('spellCheckWithZeroResults.json');
10+
searchTest = fixture.load('searchTestResponse.json');
11+
//setup document to hold search results
12+
document.body.innerHTML = __html__['index.html'];
13+
14+
//initialize search
15+
window.searchobj = new window.Unbxd.setSearch(window.config);
16+
17+
//stub search ajax call with mock response
18+
this.stub = sinon.stub(jQuery, 'ajax').yieldsTo('success',searchTest);
19+
20+
//First call should return spellcheck with zeroresuts
21+
this.stub.onFirstCall().yieldsTo('success',spellCheckTest);
22+
23+
window.searchobj.callResults(window.searchobj.paintResultSet);
24+
});
25+
26+
after(function(){
27+
this.stub.restore();
28+
});
29+
30+
it('Should display didYouMean', function(){
31+
expect(jQuery(window.searchobj.options.spellCheck).text())
32+
.to.equal('Did you mean : '+ spellCheckTest.didYouMean[0].suggestion +' ?');
33+
});
34+
35+
it('Should load results of didYouMean query',function(){
36+
expect(window.searchobj.params.query)
37+
.to.equal(spellCheckTest.didYouMean[0].suggestion);
38+
});
39+
});

0 commit comments

Comments
 (0)