Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

faussaire

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

faussaire - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

2

package.json
{
"name": "faussaire",
"version": "0.2.0",
"version": "0.2.1",
"description": "Lightweight library to mock API for testing purpose",

@@ -5,0 +5,0 @@ "main": "build/src/faussaire.js",

@@ -1,2 +0,2 @@

# Faussaire v0.2
# Faussaire v0.2.1
Lightweight javascript library to mock network request for testing purposes

@@ -3,0 +3,0 @@

@@ -5,7 +5,21 @@ import faussaire, {Route, Controller, Response} from '../src/faussaire';

faussaire
.route(Route({
template: "http://foo.com",
methods: ["GET"],
controller: Controller({
run: () => {
.route(Route({
template: "http://foo.com",
methods: ["GET"],
controller: Controller({
run: () => {
return Response({
data: {},
status: 200,
statusText: "OK"
})
}
})
}))
.route(Route({
template: "http://bar.com",
methods: ["GET", "POST"],
controller: Controller({
run: (params) => {
if(params.query.apikey || params.request.apikey){
return Response({

@@ -16,52 +30,57 @@ data: {},

})
}
})
}))
.route(Route({
template: "http://bar.com",
methods: ["GET", "POST"],
controller: Controller({
run: (params) => {
if(params.query.apikey || params.request.apikey){
return Response({
data: {},
status: 200,
statusText: "OK"
})
} else {
return Response({
data: {},
status: 403,
statusText: "Forbidden"
})
}
}
})
}))
.route(Route({
template: "http://bar.com/test",
methods: ["GET"],
controller: Controller({
run: () => {
} else {
return Response({
data: { match: "test" },
status: 200,
statusText: "OK"
data: {},
status: 403,
statusText: "Forbidden"
})
}
})
}))
.route(Route({
template: "http://bar.com/test/{id}",
methods: ["GET"],
controller: Controller({
run: () => {
return Response({
data: { match: "test with id" },
status: 200,
statusText: "OK"
})
}
})
}));
}
})
}))
.route(Route({
template: "http://bar.com/test",
methods: ["GET"],
controller: Controller({
run: () => {
return Response({
data: { match: "test" },
status: 200,
statusText: "OK"
})
}
})
}))
/*
* These routes are in this order for testing reasons, and are not put there randomly.
* This is because a call to http://bar.com/test/8/count shouldn't fall on this route but
* on the next one.
*/
.route(Route({
template: "http://bar.com/test/{id}",
methods: ["GET"],
controller: Controller({
run: () => {
return Response({
data: { match: "test with id" },
status: 200,
statusText: "OK"
})
}
})
}))
.route(Route({
template: "http://bar.com/test/{id}/count",
methods: ["GET"],
controller: Controller({
run: () => {
return Response({
data: { match: "test with id and count" },
status: 200,
statusText: "OK"
})
}
})
}))
;

@@ -140,2 +159,7 @@ it('should fetch data from a correct URL', function(){

});
it('should match http://bar.com/test/(\\d+)/count and return object to identify it with count', function(){
const response = faussaire.fetch("http://bar.com/test/10/count", "GET");
expect(response.data.match).toEqual("test with id and count");
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc