Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
run(() => {
let done = assert.async();
let profile = make('profile');
let deleteMock = mockDelete(profile).fails();
profile.destroyRecord()
.catch(() => assert.ok(true, 'delete failed the first time'))
.then(() => {
deleteMock.succeeds();
profile.destroyRecord().then(function() {
assert.equal(FactoryGuy.store.peekAll('profile').get('content.length'), 0);
done();
});
});
});
});
run(() => {
let done = assert.async();
let profile = make('profile');
mockDelete(profile);
profile.destroyRecord().then(function() {
assert.equal(FactoryGuy.store.peekAll('profile').get('content.length'), 0);
done();
});
});
});
run(() => {
let done = assert.async();
let profile = make('profile');
mockDelete('profile', profile.id);
profile.destroyRecord().then(function() {
assert.equal(FactoryGuy.store.peekAll('profile').get('content.length'), 0);
done();
});
});
});
run(() => {
let done = assert.async();
let employee = make('employee');
mockDelete(employee);
employee.destroyRecord().then(function() {
assert.equal(FactoryGuy.store.peekAll('employee').get('content.length'), 0);
done();
});
});
});
run(() => {
let done = assert.async();
let profiles = makeList('profile', 2);
let profile = profiles[0];
let deleteMock = mockDelete('profile').fails();
profile.destroyRecord()
.catch(() => assert.ok(true, 'delete failed the first time'))
.then(() => {
deleteMock.succeeds();
profile.destroyRecord().then(function() {
assert.equal(FactoryGuy.store.peekAll('profile').get('content.length'), 1);
done();
});
});
});
});
run(() => {
let done = assert.async();
let profiles = makeList('profile', 2);
let profile = profiles[0];
let deleteMock = mockDelete('profile').fails();
profile.destroyRecord()
.catch(() => assert.ok(true, 'delete failed the first time'))
.then(() => {
deleteMock.succeeds();
profile.destroyRecord().then(function() {
assert.equal(FactoryGuy.store.peekAll('profile').get('content.length'), 1);
done();
});
});
});
});
run(() => {
let done = assert.async();
let profile = make('profile');
let mock = mockDelete('profile', profile.id).fails({status: 500});
profile.destroyRecord().catch(function(reason) {
let error = reason.errors[0];
assert.equal(error.status, "500");
assert.equal(mock.timesCalled, 1);
assert.ok(true);
done();
});
});
});
run(() => {
let done = assert.async();
let profiles = makeList('profile', 2);
let profile = profiles[0];
mockDelete('profile');
assert.equal(FactoryGuy.store.peekAll('profile').get('content.length'), 2);
profile.destroyRecord().then(function() {
assert.equal(FactoryGuy.store.peekAll('profile').get('content.length'), 1);
done();
});
});
});
run(() => {
let done = assert.async();
let profile = make('profile');
let deleteMock = mockDelete(profile).fails();
profile.destroyRecord()
.catch(() => assert.ok(true, 'delete failed the first time'))
.then(() => {
deleteMock.succeeds();
profile.destroyRecord().then(function() {
assert.equal(FactoryGuy.store.peekAll('profile').get('content.length'), 0);
done();
});
});
});
});
run(() => {
let done = assert.async();
let profiles = makeList('profile', 2);
let profile = profiles[0];
mockDelete('profile');
assert.equal(FactoryGuy.store.peekAll('profile').get('content.length'), 2);
profile.destroyRecord().then(function() {
assert.equal(FactoryGuy.store.peekAll('profile').get('content.length'), 1);
done();
});
});
});