Coder Social home page Coder Social logo

mock-http's People

Contributors

jackmellis avatar

Stargazers

 avatar

Watchers

 avatar

mock-http's Issues

http when next

http.when('/api/1').return({ data : 'foo' });
http.expect(/\/api\/\d+/).next();

http.get('api/1').then(response => {response.data === 'foo'});

so basically you can intercept a request but still return the original data.

Perhaps we should make the callbacks chainable i.e. .call(spy).stop() or .call(spy).next()

Firstly, the find matching when method should return an array of when's, so we can easily get the next one.

Secondly, callback should also be an array, so we can loop through an call all of the callbacks.

status, data

http.when('/api/success').status(200).data('ok');
http.when('/api/error').status(500).reject('broked');

response = await http.get('/api/success'); // { status : 200, data : 'ok' }
failure = await http.get('/api/error'); // Error { status : 500, message : 'broked' }

data and body should accept a function as well. It no status, data adds a default status of 200.

Configure the data transformer:

http.transformResponse = (status, data) => ({status, body : data});

Decouple from vue inject

I think the only thing it uses it for it $promise. Could get around this by saying if jpex ecists and $promise exists, use it, otherwise just default to global Promise class

expect(url, count) fails

when calling http.expect('/api', 3) it assumes this means a method of /api and a url of 3. It should check if count is undefined and url is a number, then shift all values across one.

expect / assert

So you can say this test expects this request, then after the test call assert which checks that all expected calls have been made

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.