Comparing version 0.2.0 to 0.2.1
{ | ||
"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"); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25905
395
1