test/helpers/apiMock.js
/**
 * Init API mock as a whole.
 */
Init API mock as a whole.
Init API mock as a whole .
function prepare () {
  fetchMock.mock(apiUrl(), responses.ok)
  fetchMock.mock(/\?.*/, responses.ok)
  fetchMock.mock(`${paths.testBase}${paths.dummy}`, responses.ok)
  fetchMock.get(apiUrl(paths.error), responses.error.generic)
  fetchMock.get(apiUrl(paths.access), (url, opts) => validAccess(opts))
  fetchMock.get(apiUrl(paths.dummy), responses.entity.multiple)
  fetchMock.post(apiUrl(paths.dummy), responses.entity.one)
  fetchMock.put(apiUrl(paths.dummy), responses.entity.one)
  fetchMock.delete(apiUrl(paths.dummy), responses.noContent)
  fetchMock.get(apiUrl(paths.operator), responses.operator.one)
  fetchMock.post(apiUrl(paths.operators), responses.operator.one)
  fetchMock.put(apiUrl(paths.operator), responses.operator.one)
  fetchMock.get(apiUrl(paths.application), responses.application.one)
  fetchMock.put(apiUrl(paths.application), responses.application.one)
  fetchMock.post(apiUrl(`${paths.dummy}/${paths.usersAccessValidate}`), responses.ok)
  fetchMock.post(apiUrl(`${paths.usersAccess}/${paths.usersAccessValidate}`), responses.ok)
}
function prepare ( ) { fetchMock . mock ( apiUrl ( ) , responses . ok ) fetchMock . mock ( / \?.* / , responses . ok ) fetchMock . mock ( ` ${ paths . testBase } ${ paths . dummy } ` , responses . ok ) fetchMock . get ( apiUrl ( paths . error ) , responses . error . generic ) fetchMock . get ( apiUrl ( paths . access ) , ( url , opts ) => validAccess ( opts ) ) fetchMock . get ( apiUrl ( paths . dummy ) , responses . entity . multiple ) fetchMock . post ( apiUrl ( paths . dummy ) , responses . entity . one ) fetchMock . put ( apiUrl ( paths . dummy ) , responses . entity . one ) fetchMock . delete ( apiUrl ( paths . dummy ) , responses . noContent ) fetchMock . get ( apiUrl ( paths . operator ) , responses . operator . one ) fetchMock . post ( apiUrl ( paths . operators ) , responses . operator . one ) fetchMock . put ( apiUrl ( paths . operator ) , responses . operator . one ) fetchMock . get ( apiUrl ( paths . application ) , responses . application . one ) fetchMock . put ( apiUrl ( paths . application ) , responses . application . one ) fetchMock . post ( apiUrl ( ` ${ paths . dummy } ${ paths . usersAccessValidate } ` ) , responses . ok ) fetchMock . post ( apiUrl ( ` ${ paths . usersAccess } ${ paths . usersAccessValidate } ` ) , responses . ok ) }
Init API mock as a whole.
Init API mock as a whole .
// Root - generic requests handles // Unavailable/error endpoint // Access // Dummy resource path for entities // Operator // Application // Validate user