open-vault/ui/tests/helpers/noop-all-api-requests.js
Hamid Ghaf 27bb03bbc0
adding copyright header (#19555)
* adding copyright header

* fix fmt and a test
2023-03-15 09:00:52 -07:00

24 lines
582 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Pretender from 'pretender';
import { noopStub } from './stubs';
/**
* DEPRECATED prefer to use `setupMirage` along with stubs in vault/tests/helpers/stubs
*/
export default function (options = { usePassthrough: false }) {
return new Pretender(function () {
let fn = noopStub();
if (options.usePassthrough) {
fn = this.passthrough;
}
this.post('/v1/**', fn);
this.put('/v1/**', fn);
this.get('/v1/**', fn);
this.delete('/v1/**', fn || noopStub(204));
});
}