assert.equal(result.texture._refs, 0); assert.equal(spy.callCount, 1); assert.ok(spy.calledWith(result.texture)); spy.restore(); done();
it('check entire form validation when the email is invalid', () => { let formSpy = spy(); const form = mount(<Form isFormValid={formSpy} />); form.find('#name').simulate('change', { target: { value: 'ui' } }); form.find('#email').simulate('change', { target: { value: 'abc@xyz.' } }); form.find('#phone').simulate('change', { target: { value: '56756756' } }); form.find('#url').simulate('change', { target: { value: 'http://google.com' } }); form.find('#button').simulate('click'); expect(formSpy.calledWith(true)).toEqual(false); });
describe('Server generation without input file', () => { before(() => { generate.configure(options_object); }); it('An error is thrown', () => { const spy = sinon.spy(console, 'log'); generate.generateServer(null, cmd); spy.calledWith('You must select an input specification file!').should.equal(true); spy.restore(); }); });
test('it should log errors in case of incomprehensible message', t => { t.plan(1); const batchSocket = sinon.stub(); const exit = sinon.stub(); const logger = {error: sinon.spy()}; const dealer = createDealer(batchSocket, exit, logger); const rawMessage = new Buffer(JSON.stringify({type: 'something'})); dealer(rawMessage); t.ok(logger.error.calledWith('invalid message received from server', '{"type":"something"}'), 'error info logged'); });
it('calls handlers for an event with the passed payload', function(done) { const handler = sinon.spy(); const burns = require('../../src/burns'); burns.registerEvents({ eventW: handler }); const eventPayload = { key: 'value' }; burns.dispatch('eventW', eventPayload); setTimeout(() => { expect(handler.calledOnce).to.equal(true); expect(handler.calledWith(eventPayload)).to.equal(true); done(); }, 0); });
it('if accept-version header is present, ' + 'appropriate callback should be called', function() { var version1Spy = sinon.spy(); var version2Spy = sinon.spy(); var middleware = routesVersioning({ "1.2.1": version1Spy, "1.3.1": version2Spy }); req.headers = {}; req.headers["accept-version"] = "1.2.1"; middleware(req, res, next); assert.ok(version1Spy.calledOnce); assert.ok(version1Spy.calledWith(req, res, next)); });
it('Testcase - no DB calls emit disconnect', function(done) { dbInfoStub.returns(Promise.reject()); var store = new CloudantStore({ client: client }); var emitSpy = sinon.spy(store, 'emit'); setTimeout(function() { expect(emitSpy.calledWith('disconnect')).to.be.true; done(); }, 0); expect(store).to.be.ok; });
it('if version is not provided by client, ' + 'and NoMatchFoundCallback if provided is called', function() { var NoMatchFoundSpy = sinon.spy(); var middleware = routesVersioning({}, NoMatchFoundSpy); middleware(req, res, next); assert.ok(NoMatchFoundSpy.calledOnce); assert.ok(NoMatchFoundSpy.calledWith(req, res, next)); });
it('should call to actions.setSearchText when search input text changes', () => { const setSearchText = spy() const props = { actions: { setSearchText } } const wrapper = shallow(<WeatherSearch {...props} />) const fakeEvent = {target: {value: 'City Name'}} wrapper.find('input').simulate('change', fakeEvent) expect(setSearchText.calledOnce).equal(true) expect(setSearchText.calledWith(fakeEvent.target.value)).equal(true) })
it('when ~ is used in version, version should matching appropriately', function() { var version1Spy = sinon.spy(); var version2Spy = sinon.spy(); var middleware = routesVersioning({ "~1.2.1": version1Spy, "2.3.1": version2Spy }); req.version = "1.2.9"; middleware(req, res, next); assert.ok(version1Spy.calledOnce); assert.ok(version1Spy.calledWith(req, res, next)); });
it('check entire form validation when the url is invalid', () => { let formSpy = spy(); const form = mount(<Form isFormValid={formSpy} />); form.find('#name').simulate('change', { target: { value: 'ui' } }); form.find('#email').simulate('change', { target: { value: 'abc@xyz.com' } }); form.find('#phone').simulate('change', { target: { value: '56756756' } }); form.find('#url').simulate('change', { target: { value: 'ht' } }); form.find('#button').simulate('click'); expect(formSpy.calledWith(true)).toEqual(false); });
it('check entire form validation when the phone number is invalid', () => { let formSpy = spy(); const form = mount(<Form isFormValid={formSpy} />); form.find('#name').simulate('change', { target: { value: 'ui' } }); form.find('#email').simulate('change', { target: { value: 'abc@xyz.com' } }); form.find('#phone').simulate('change', { target: { value: '56756756' } }); form.find('#url').simulate('change', { target: { value: 'http://google.com' } }); form.find('#button').simulate('click'); expect(formSpy.calledWith(true)).toEqual(false); });
it('check entire form validation when the form is valid', () => { let formSpy = spy(); const form = mount(<Form isFormValid={formSpy} />); form.find('.name').simulate('change', { target: { name:'name', value: 'sasrank' } }); form.find('#email').simulate('change', { target: { name:'email' ,value: 'aasdbc@xyz.com' } }); form.find('#phone').simulate('change', { target: { name:'phone', value: '9856756756' } }); form.find('#url').simulate('change', { target: { name:'url' , value: 'http://google.com' } }); form.find('#button').simulate('click'); expect(formSpy.calledWith(true)).toEqual(true); });
it('when version provided as integer, version should cast to string', function() { var version1Spy = sinon.spy(); var middleware = routesVersioning({ "1": version1Spy, }); req.version = 1; middleware(req, res, next); assert.ok(version1Spy.calledOnce); assert.ok(version1Spy.calledWith(req, res, next)); });
it('check form validation when the entire form is invalid', () => { let formSpy = spy(); const form = mount(<Form isFormValid={formSpy} />); form.find('#name').simulate('change', { target: { value: '' } }); form.find('#email').simulate('change', { target: { value: '33' } }); form.find('#phone').simulate('change', { target: { value: '567567560' } }); form.find('#url').simulate('change', { target: { value: 'h9' } }); form.find('#button').simulate('click'); expect(formSpy.calledWith(true)).toEqual(false); });