Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
beforeAll(async () => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000; // These asynchronous tests can take a bit longer than normal.
mockCasFetch = fetchMock.sandbox().get('*', 404); // Setting the CAS to always return 404.
cas = new CasClient(config.contentAddressableStoreServiceUri, mockCasFetch);
downloadManager = new DownloadManager(config.maxConcurrentDownloads, cas);
operationStore = new MockOperationStore();
operationProcessor = new OperationProcessor(config.didMethodName, operationStore);
downloadManager.start();
});
test('PersonBadge renders properly', async t => {
const mockServer = mockFetch.sandbox()
mockServer.get(`begin:${APP_URL}/api/badge`, { body: [...badgeData] })
const person = {
_id: 'taskldjfh0'
}
global.fetch = mockServer
const PersonBadgeRendered = mount()
t.true(PersonBadgeRendered.exists())
})
it('handles errors in expected format', function (done) {
const fetchMock = FetchMock.sandbox().mock('*', function () {
return {
status: 500,
body: JSON.stringify(exampleErr),
headers: {
'Content-Type': 'application/json',
},
};
}).catch(500);
rpcRequest(fetchMock)('files/list', { foo: 'bar' }, 'user', 'api', 'atoken')
.then(function (data) {
done(new Error('shouldn’t reach this callback'));
})
.catch(function (err) {
assert(err);
assert.equal(err.status, 500);
function makeFetchMock (opportunityId) {
const myMock = fetchMock.sandbox()
myMock.get(API_URL + '/interests/?op=' + opportunityId, { body: { status: 200 } })
return myMock
}
beforeEach(function () {
fetchMock = FetchMock.sandbox().post('*', new Response(
'{"foo": "bar"}',
{
status: 200,
statusText: "OK",
headers: {
'Content-Type': 'application/json',
'dropbox-api-result': '{"test":"json"}'
}
}
));
});
beforeEach(function () {
fetchMock = FetchMock.sandbox().mock('*', new Response(
'{"test": "test"}',
{
status: 200,
statusText: "OK",
headers: {
'Content-Type': 'application/json',
'dropbox-api-result': '{"test":"json"}'
}
}
));
});
afterEach(() => {
fetchMock.sandbox().reset();
fetchMock.reset();
});
beforeEach(() => {
fetchMock = require('fetch-mock').sandbox();
window.fetch = fetchMock;
fetchMock.get('https://unpkg.com/@stoplight/spectral/rulesets/oas/index.json', {
status: 200,
body: JSON.parse(JSON.stringify(oasRuleset)),
});
fetchMock.get('https://unpkg.com/@stoplight/spectral/rulesets/oas/schemas/schema.oas2.json.json', {
status: 200,
body: JSON.parse(JSON.stringify(oas2Schema)),
});
fetchMock.get('https://unpkg.com/@stoplight/spectral/rulesets/oas/schemas/schema.oas3.json.json', {
status: 200,
body: JSON.parse(JSON.stringify(oas3Schema)),
});
const setup = () => {
const history = createHistory({ initialEntries: ['/'] });
const store = configureStore(fromJS({}), history);
const request = (opts) => store.runSaga(apiRequest, opts).done;
const fetch = fetchMock.sandbox();
const tree = nest(
[StoreProvider, { store }],
[APIProvider, { fetch, base }],
() => <h1>sup</h1>,
);
return { request, fetch, tree };
};