2021-11-11 11:23:49 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import ReviewBar from '~/batch_comments/components/review_bar.vue';
|
|
|
|
import { REVIEW_BAR_VISIBLE_CLASS_NAME } from '~/batch_comments/constants';
|
|
|
|
import createStore from '../create_batch_comments_store';
|
|
|
|
|
|
|
|
describe('Batch comments review bar component', () => {
|
|
|
|
let store;
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
const createComponent = (propsData = {}) => {
|
|
|
|
store = createStore();
|
|
|
|
|
|
|
|
wrapper = shallowMount(ReviewBar, {
|
|
|
|
store,
|
|
|
|
propsData,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
document.body.className = '';
|
|
|
|
});
|
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
it('adds review-bar-visible class to body when review bar is mounted', async () => {
|
2022-10-02 17:18:49 +05:30
|
|
|
expect(document.body.classList.contains(REVIEW_BAR_VISIBLE_CLASS_NAME)).toBe(false);
|
2021-11-11 11:23:49 +05:30
|
|
|
|
2022-10-02 17:18:49 +05:30
|
|
|
createComponent();
|
2021-11-11 11:23:49 +05:30
|
|
|
|
2022-10-02 17:18:49 +05:30
|
|
|
expect(document.body.classList.contains(REVIEW_BAR_VISIBLE_CLASS_NAME)).toBe(true);
|
2021-11-11 11:23:49 +05:30
|
|
|
});
|
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
it('removes review-bar-visible class to body when review bar is destroyed', async () => {
|
2022-10-02 17:18:49 +05:30
|
|
|
createComponent();
|
2021-11-11 11:23:49 +05:30
|
|
|
|
2022-10-02 17:18:49 +05:30
|
|
|
wrapper.destroy();
|
2022-08-27 11:52:29 +05:30
|
|
|
|
2022-10-02 17:18:49 +05:30
|
|
|
expect(document.body.classList.contains(REVIEW_BAR_VISIBLE_CLASS_NAME)).toBe(false);
|
2021-11-11 11:23:49 +05:30
|
|
|
});
|
|
|
|
});
|