open-vault/ui/tests/helpers/noop-all-api-requests.js
Matthew Irish 7f4dbe3fd2
Ui kv v2 redux (#4393)
* remove header used for backwards compatibility in KV mounts, and use v1 paths for v1, v2 paths for v2

* make the model hook always run

* simplify adapter & serializer code for secrets

* update tests

* fix lease tests

* address review feedback
2018-04-19 21:26:25 -05:00

21 lines
503 B
JavaScript

import Pretender from 'pretender';
const noop = response => {
return function() {
return [response, { 'Content-Type': 'application/json' }, JSON.stringify({})];
};
};
export default function(options = { usePassthrough: false }) {
return new Pretender(function() {
let fn = noop();
if (options.usePassthrough) {
fn = this.passthrough;
}
this.post('/v1/**', fn);
this.put('/v1/**', fn);
this.get('/v1/**', fn);
this.delete('/v1/**', fn || noop(204));
});
}