fantactuka / jasmine-sugar Goto Github PK
View Code? Open in Web Editor NEWSome widely used Jasmine helpers
Some widely used Jasmine helpers
It would be helpful to have listener functionality that will resolve ajax request by matching url:
beforeEach(function() {
jasmine.Ajax.listen('users/.*', { id: 1, name: 'Tom' });
jasmine.Ajax.listen('404', null, { status: 404 });
});
it('fetches model', function() {
$.ajax('users/1');
// Will be immediately resolved with { id: 1, name: 'Tom' }
// In fact it wil be the same if you call Ajax.mostRecentCall.respond({ id: 1, name: 'Tom' });
});
There should be easier way to respond to mocked ajax calls:
respond
method for the latest requestAjax.respond({ message: 'Hello!' }); // Content-type: 'application/json', status: 200
Ajax.respond('<div>Hello!</div>'); // Content-type: 'text/html', status: 200
Ajax.respond(null, { status: 500 });
Ajax.calls[3].respond({ message: 'Hello!' });
Since we response right inside send
method call via _respondForListeners
it sets readyState
to 4
and jQuery runs callback via setTimeout( callback )
(https://github.com/jquery/jquery/blob/1.10.1/src/ajax/xhr.js#L182) that causes asynchronous callback
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.