2020-06-23 00:09:42 +05:30
|
|
|
import { shallowMount, mount } from '@vue/test-utils';
|
|
|
|
import axios from 'axios';
|
|
|
|
import MockAdapter from 'axios-mock-adapter';
|
|
|
|
import AlertSidebar from '~/alert_management/components/alert_sidebar.vue';
|
|
|
|
import SidebarAssignees from '~/alert_management/components/sidebar/sidebar_assignees.vue';
|
2020-07-28 23:09:34 +05:30
|
|
|
import mockAlerts from '../../mocks/alerts.json';
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
const mockAlert = mockAlerts[0];
|
|
|
|
|
|
|
|
describe('Alert Details Sidebar', () => {
|
|
|
|
let wrapper;
|
|
|
|
let mock;
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
function mountComponent({ mountMethod = shallowMount, stubs = {}, alert = {} } = {}) {
|
2020-06-23 00:09:42 +05:30
|
|
|
wrapper = mountMethod(AlertSidebar, {
|
2020-07-28 23:09:34 +05:30
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
sidebarStatus: false,
|
|
|
|
};
|
|
|
|
},
|
2020-06-23 00:09:42 +05:30
|
|
|
propsData: {
|
|
|
|
alert,
|
2020-07-28 23:09:34 +05:30
|
|
|
},
|
|
|
|
provide: {
|
2020-06-23 00:09:42 +05:30
|
|
|
projectPath: 'projectPath',
|
2020-07-28 23:09:34 +05:30
|
|
|
projectId: '1',
|
2020-06-23 00:09:42 +05:30
|
|
|
},
|
|
|
|
stubs,
|
2020-07-28 23:09:34 +05:30
|
|
|
mocks: {
|
|
|
|
$apollo: {
|
|
|
|
queries: {
|
|
|
|
sidebarStatus: {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
if (wrapper) {
|
|
|
|
wrapper.destroy();
|
|
|
|
}
|
|
|
|
mock.restore();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('the sidebar renders', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
mock = new MockAdapter(axios);
|
|
|
|
mountComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('open as default', () => {
|
2020-07-28 23:09:34 +05:30
|
|
|
expect(wrapper.classes('right-sidebar-expanded')).toBe(true);
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should render side bar assignee dropdown', () => {
|
|
|
|
mountComponent({
|
|
|
|
mountMethod: mount,
|
|
|
|
alert: mockAlert,
|
|
|
|
});
|
|
|
|
expect(wrapper.find(SidebarAssignees).exists()).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|