Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should dispatch FETCH_COMPLETE with a text object', async () => {
const store = getStore();
fetchMock.mock('http://localhost:3000/api/test', { body: 'string' });
store.dispatch({
type: ACTION_FETCH_START,
payload: {
requestedAt: 1478329954380,
name: 'TEST_API',
endpoint: 'http://localhost:3000/api/test',
},
});
const [_, complete] = await takeActionsUntil(store, 2);
expect(complete).toEqual({
type: ACTION_FETCH_COMPLETE,
payload: {
name: 'TEST_API',
it('Morphing to a URL should dispatch the event after a successful request', async () => {
const rel = getTestURL('newUrl', true);
fetchMock.mock(rel, {
status: 200,
body: '{"hello": "world"}'
});
let firedEvent;
const handler = event => {
firedEvent = event;
window.removeEventListener(
'palindrom-after-redirect',
handler
);
};
window.addEventListener(
it('makes a PUT request to baseURL + path', () => {
const url = `${TEST_URL}/foo`;
fetchMock.mock(url, {
status : 200,
body : {
foo: 'bar'
},
headers: {
'Content-Type': 'application/json'
}
}, {
method: 'put'
});
const testTrae = trae.create();
testTrae.before((c) => {
expect(c.headers).toMatchSnapshot();
return c;
it('should be created if they are provided on the root path', async () => {
const store = mockStore(initialState);
const snapUrl =
'https://gu.com?gu-snapType=json.html&gu-snapUri=https://interactive.guim.co.uk/atoms/2019/03/29/unmeaningful-vote/snap/snap.json';
fetchMock.mock(snapUrl, JSON.stringify({}));
await store.dispatch(createArticleEntitiesFromDrop(
idDrop(snapUrl)
) as any);
const actions = store.getActions();
expect(actions[0]).toEqual(
cardsReceived({
card1: {
frontPublicationDate: 1487076708000,
id: 'snap/1487076708000',
meta: {
byline: undefined,
trailText: undefined,
showByline: false,
snapType: 'json.html',
snapUri:
'https://interactive.guim.co.uk/atoms/2019/03/29/unmeaningful-vote/snap/snap.json'
beforeEach(function() {
fetchMock.mock(
`begin:${API_URL}/attask/api`,
fixture,
{
name: 'create'
}
)
})
it("should pass headers in the request", function(){
fetchMock
.mock(endpoint, {body: {hello: "world"}});
var headers = { "foo": "bar", "n": 42 };
var authorizer = new Authorizer(
{ name: "chan" },
{ authTransport: "ajax",
authEndpoint: endpoint,
auth: {
headers: headers
}
}
);
authorizer.authorize("1.23", function() {});
var lastCall = fetchMock.lastCall(endpoint)[0];
beforeEach(() => {
fetchMock.mock('begin:https://analytics.manifold.co', 200);
fetchMock.mock('begin:https://api.manifold.co', 200);
});
beforeEach(() => {
fetchMock.mock('begin:https://analytics.manifold.co', 200);
fetchMock.mock('begin:https://api.manifold.co', 200);
});