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 fetch all of the front collections, mark first collections as open, and fetch articles and their analytics data for first collections', async () => {
fetchMock.postOnce('/collections', scJohnsonPartnerZoneCollection);
fetchMock.post('begin:/stories-visible', {
desktop: 2,
mobile: 4
});
fetchMock.once(
'begin:/api/preview/search?ids=internal-code/page/5607373,internal-code/page/5607569',
articlesForScJohnsonPartnerZone
);
// @todo -- this isn't checking the correct thing -- we'd expect article paths in this string.
// See below -- the articles don't end up in the state as expected.
fetchMock.get(
'/ophan/histogram?referring-path=/sc-johnson-partner-zone&hours=1&interval=10',
[]
);
it('should build proper request with no body', async () => {
fetchMock.postOnce('https://samples.auth0.com/method', response);
expect.assertions(1);
await client.post('/method');
expect(fetchMock.lastCall()).toMatchSnapshot();
});
it('send sms, post plain object', () => {
fetchMock.postOnce('end:/account/~/extension/~/sms', {});
let reqBody = {
from: { phoneNumber: '+17322764403' },
text: 'test sms text content.',
to: [{ phoneNumber: '+16507411615' }],
};
return rc.account().extension().sms().post(reqBody).then(sms => {
expect(fetchMock.lastOptions().body).to.deep.eq(JSON.stringify(reqBody));
});
});
export async function auth() {
let rc = new RingCentral({ appKey: 'testAppKey', appSecret: 'testAppSecret' });
let serverToken = {
access_token: 'MockAccessToken',
token_type: 'bearer',
expires_in: 3600,
refresh_token: 'MockRefreshToken',
refresh_token_expires_in: 604800,
scope: 'ReadMessages Faxes ReadPresence EditCallLog VoipCalling ReadClientInfo Glip Interoperability Contacts ReadAccounts EditExtensions RingOut SMS InternalMessages SubscriptionWebhook EditMessages',
owner_id: 'MockOwnerId',
endpoint_id: 'MockEndpointId'
};
fetchMock.postOnce('*', serverToken);
await rc.auth({ username: 'testUserName', password: 'testPassword' });
return rc;
}
const projectId = config._boundToObjectId as ProjectId
const configIds = [configId]
const configs = [config]
fetchMock.getOnce('*', [])
const configs$ = sdk
.getScenarioFieldConfigs(projectId, 'event')
.take(1)
.subscribeOn(Scheduler.asap)
yield configs$.do((result) => {
expect(result).to.be.empty
})
fetchMock.postOnce('*', configs)
yield sdk
.bulkAddScenarioFieldConfigs(projectId, 'event', configIds)
.subscribeOn(Scheduler.asap)
.do(([result]) => {
assertScenarioFieldConfig(result, configs[0])
})
yield configs$.do(([result]) => {
assertScenarioFieldConfig(result, configs[0])
})
})
function newTaskQueue(parentSelector: string) {
fetchMock.config.overwriteRoutes = false;
fetchMock.postOnce('begin:/_/get_', resultSetTwoItems);
fetchMock.postOnce('begin:/_/get_', singleResultCanDelete);
fetchMock.postOnce('begin:/_/get_', singleResultNoDelete);
fetchMock.post('begin:/_/get_', 200, { repeat: 13 });
const tq = document.createElement('task-queue-sk');
($$(parentSelector) as HTMLElement).appendChild(tq);
}
function newTaskQueue(parentSelector: string) {
fetchMock.config.overwriteRoutes = false;
fetchMock.postOnce('begin:/_/get_', resultSetTwoItems);
fetchMock.postOnce('begin:/_/get_', singleResultCanDelete);
fetchMock.postOnce('begin:/_/get_', singleResultNoDelete);
fetchMock.post('begin:/_/get_', 200, { repeat: 13 });
const tq = document.createElement('task-queue-sk');
($$(parentSelector) as HTMLElement).appendChild(tq);
}
function newTaskQueue(parentSelector: string) {
fetchMock.config.overwriteRoutes = false;
fetchMock.postOnce('begin:/_/get_', resultSetTwoItems);
fetchMock.postOnce('begin:/_/get_', singleResultCanDelete);
fetchMock.postOnce('begin:/_/get_', singleResultNoDelete);
fetchMock.post('begin:/_/get_', 200, { repeat: 13 });
const tq = document.createElement('task-queue-sk');
($$(parentSelector) as HTMLElement).appendChild(tq);
}