Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
expect(newPost.title).to.eq('Updated Title');
expect(newPost.user).to.eq(user2);
expect(parentSession.get(newPost).title).to.eq('Updated Title');
//
// Destroying
//
session = parentSession.child();
let comment = session.getBy(Comment, { id: 4 });
session.destroy(comment);
expect(comment.isDeleted).to.be.true;
expect(parentSession.get(comment).isDeleted).to.be.false;
fetchMock.delete('/comments/4', JSON.stringify({}));
await session.flush();
expect(parentSession.get(comment).isDeleted).to.be.true;
});
it('onDeleteClick', () => {
fetchMock.delete(API + PID, { pid: PID });
const store = mockStore(data);
const props = mapDispatchToProps(store.dispatch);
expect(props.onDeleteClick).to.be.a('function');
props.onDeleteClick({ pid: PID });
return actionExpects(store,
{
type: DELETE_PROJECT,
payload: { pid: PID },
meta: { asyncAction: REQUEST_SENT },
},
{
type: DELETE_PROJECT,
payload: { pid: PID },
meta: { asyncAction: REPLY_RECEIVED },
},
action => {
beforeEach(function() {
fetchMock.delete('/posts/1', JSON.stringify({}));
});
it('should set state.entry to undefined, mark state.entries[entryIndex] for deletion, provide a callback to set, and not remove the entry when the network call fails', (done) => {
fetchMock.delete('/api/entry/0', 500);
Entry.deleteEntry(el, { id: 0 });
const firstCallArgs = el.set.args[0];
expect(firstCallArgs[0].entry).to.be.undefined;
expect(firstCallArgs[0].entries[0].needsSync).to.be.true;
expect(firstCallArgs[0].entries[0].deleted).to.be.true;
expect(firstCallArgs[0].entries[0].text).to.equal('');
expect(typeof firstCallArgs[1]).to.equal('function');
setTimeout(() => {
expect(el.set.calledTwice).to.be.false;
expect(console.log.calledWith('deleteEntryFailure')).to.be.true;
done();
});
});
it("removeCompany() - should persist a company removal", async () => {
fetchMock.delete("/api/companies/1", {
body: getCompany()
});
const expectedActions = [
{
type: types.DELETE,
payload: normalize(getCompany()),
messages: {
success: [{ msg: "Successfully deleted your company." }]
}
}
];
const store = mockStore({
companies: {
byId: {},
it('should set state.entry to undefined, mark state.entries[entryIndex] for deletion, provide a callback to set, and remove the correct entry when the network call succeedes', (done) => {
fetchMock.delete('/api/entry/0', 204);
Entry.deleteEntry(el, { id: 0 });
const firstCallArgs = el.set.args[0];
expect(firstCallArgs[0].entry).to.be.undefined;
expect(firstCallArgs[0].entries[0].needsSync).to.be.true;
expect(firstCallArgs[0].entries[0].deleted).to.be.true;
expect(firstCallArgs[0].entries[0].text).to.equal('');
expect(typeof firstCallArgs[1]).to.equal('function');
setTimeout(() => {
const secondCallArgs = el.set.args[1];
expect(secondCallArgs[0].entries.length).to.equal(0);
done();
});
});
it('should call the del endpoint', (done) => {
fetchMock.delete('/api/entry/1234', 204);
Entry.del(1234).then(done).catch(done);
});
it('should sync entries from the client to the server when one or more entries has the needsSync flag', (done) => {
fetchMock.get('/api/entries/sync/1234', {
status: 200,
body: {
entries: [],
timestamp: 4321
}
});
fetchMock.post('/api/entry', {
status: 200,
body: { id: 3 }
});
fetchMock.patch('/api/entry/1', 204);
fetchMock.delete('/api/entry/2', 204);
el.state.loggedIn = true;
el.state.timestamp = 1234;
el.state.entries = [
{ id: 0, date: '2018-01-01', text: 'bogus', newEntry: true, needsSync: true },
{ id: 1, date: '2017-01-01', text: 'what', needsSync: true },
{ id: 2, deleted: true, needsSync: true },
];
Entry.getEntries(el);
setTimeout(() => {
const entries = el.state.entries;
expect(entries.length).to.equal(2);
expect(entries[0].id).to.equal(3);
expect(entries[0].newEntry).to.be.undefined;
expect(entries[0].needsSync).to.be.undefined;
expect(entries[1].needsSync).to.be.undefined;
describe('backend sync', () => {
const updateTabStateEndpoint = 'glob:*/tabstateview/*';
fetchMock.put(updateTabStateEndpoint, {});
fetchMock.delete(updateTabStateEndpoint, {});
fetchMock.post(updateTabStateEndpoint, JSON.stringify({ id: 1 }));
const updateTableSchemaEndpoint = 'glob:*/tableschemaview/*';
fetchMock.put(updateTableSchemaEndpoint, {});
fetchMock.delete(updateTableSchemaEndpoint, {});
fetchMock.post(updateTableSchemaEndpoint, JSON.stringify({ id: 1 }));
const getTableMetadataEndpoint = 'glob:*/superset/table/*';
fetchMock.get(getTableMetadataEndpoint, {});
const getExtraTableMetadataEndpoint =
'glob:*/superset/extra_table_metadata/*';
fetchMock.get(getExtraTableMetadataEndpoint, {});
let isFeatureEnabledMock;
beforeAll(() => {
beforeEach(() => {
fetchMock
.delete(`glob:/api/${prefix}/1/${itemPrefix}/*`, {})
.get('/api/tasks', [
{ name: 'task 1' },
{
name: 'task 2',
},
])
.post('/api/tasks/execute', 200)
.catch();
});