Commit 607f1b01 authored by Eulyeon Ko's avatar Eulyeon Ko

Refactor systemNote spec

parent 88c6e9a4
...@@ -24,6 +24,9 @@ describe('system note component', () => { ...@@ -24,6 +24,9 @@ describe('system note component', () => {
const findDescriptionVersion = () => wrapper.find('.description-version'); const findDescriptionVersion = () => wrapper.find('.description-version');
const findDeleteDescriptionVersionButton = () =>
wrapper.find({ ref: 'deleteDescriptionVersionButton' });
beforeEach(() => { beforeEach(() => {
props = { props = {
note: { note: {
...@@ -95,45 +98,28 @@ describe('system note component', () => { ...@@ -95,45 +98,28 @@ describe('system note component', () => {
}); });
describe('click on delete icon button', () => { describe('click on delete icon button', () => {
beforeEach(done => { beforeEach(() => {
mockFetchDiff(); mockFetchDiff();
const button = findBlankBtn(); const button = findBlankBtn();
button.trigger('click'); button.trigger('click');
return wrapper.vm return waitForPromises();
.$nextTick()
.then(() => waitForPromises())
.then(() => {
done();
});
}); });
it('does not delete description diff if the delete request fails', done => { it('does not delete description diff if the delete request fails', () => {
mockDeleteDiff(503); mockDeleteDiff(503);
let deleteButton = wrapper.find({ ref: 'deleteDescriptionVersionButton' }); findDeleteDescriptionVersionButton().trigger('click');
deleteButton.trigger('click'); return waitForPromises().then(() => {
return wrapper.vm expect(findDeleteDescriptionVersionButton().exists()).toBe(true);
.$nextTick() });
.then(() => waitForPromises())
.then(() => {
deleteButton = wrapper.find({ ref: 'deleteDescriptionVersionButton' });
expect(deleteButton.exists()).toBe(true);
done();
});
}); });
it('deletes description diff if the delete request succeeds', done => { it('deletes description diff if the delete request succeeds', () => {
mockDeleteDiff(); mockDeleteDiff();
let deleteButton = wrapper.find({ ref: 'deleteDescriptionVersionButton' }); findDeleteDescriptionVersionButton().trigger('click');
deleteButton.trigger('click'); return waitForPromises().then(() => {
return wrapper.vm expect(findDeleteDescriptionVersionButton().exists()).toBe(false);
.$nextTick() expect(findDescriptionVersion().text()).toContain('Deleted');
.then(() => waitForPromises()) });
.then(() => {
deleteButton = wrapper.find({ ref: 'deleteDescriptionVersionButton' });
expect(deleteButton.exists()).toBe(false);
expect(findDescriptionVersion().text()).toContain('Deleted');
done();
});
}); });
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment