|
| 1 | +describe('Redirect', function () { |
| 2 | + var expect = window.expect; |
| 3 | + |
| 4 | + before(function(){ |
| 5 | + fixture.setBase('mock'); |
| 6 | + var RedirectTest = fixture.load('redirect.json'); |
| 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',RedirectTest); |
| 15 | + |
| 16 | + this.spyOnIntialResultLoad = sinon.spy(window.searchobj.options, |
| 17 | + 'onIntialResultLoad'); |
| 18 | + |
| 19 | + //stubbing _internalPaintResultSet here to avoid page reload |
| 20 | + this.stubInternalPaintResultSet = sinon.stub(window.searchobj, |
| 21 | + '_internalPaintResultSet'); |
| 22 | + this.stubInternalPaintResultSet.withArgs(RedirectTest,true).returns(false); |
| 23 | + |
| 24 | + window.searchobj.callResults(window.searchobj.paintResultSet); |
| 25 | + }); |
| 26 | + |
| 27 | + after(function(){ |
| 28 | + this.stub.restore(); |
| 29 | + this.stubInternalPaintResultSet.restore(); |
| 30 | + }); |
| 31 | + |
| 32 | + it('Should not call onIntialResultLoad',function(){ |
| 33 | + expect(this.spyOnIntialResultLoad.called).to.equal(false); |
| 34 | + }); |
| 35 | + |
| 36 | + it('Should have redirect in response', function(){ |
| 37 | + expect(this.stubInternalPaintResultSet.args[0][0] |
| 38 | + .hasOwnProperty('redirect')).to.equal(true); |
| 39 | + }); |
| 40 | + |
| 41 | + it('paintResultSet - Should return false',function(){ |
| 42 | + expect(this.stubInternalPaintResultSet.returned(false)).to.equal(true); |
| 43 | + }); |
| 44 | +}); |
0 commit comments