2018-12-17 16:17:25 -05:00
|
|
|
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
|
|
|
import Callout from '~/vue_shared/components/callout.vue';
|
|
|
|
|
|
|
|
const TEST_MESSAGE = 'This is a callout message!';
|
|
|
|
const TEST_SLOT = '<button>This is a callout slot!</button>';
|
|
|
|
|
|
|
|
const localVue = createLocalVue();
|
2018-04-19 03:20:53 -04:00
|
|
|
|
|
|
|
describe('Callout Component', () => {
|
2018-12-17 16:17:25 -05:00
|
|
|
let wrapper;
|
2018-04-19 03:20:53 -04:00
|
|
|
|
2018-12-17 16:17:25 -05:00
|
|
|
const factory = options => {
|
|
|
|
wrapper = shallowMount(localVue.extend(Callout), {
|
|
|
|
localVue,
|
|
|
|
...options,
|
|
|
|
});
|
|
|
|
};
|
2018-04-19 03:20:53 -04:00
|
|
|
|
|
|
|
afterEach(() => {
|
2018-12-17 16:17:25 -05:00
|
|
|
wrapper.destroy();
|
2018-04-19 03:20:53 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render the appropriate variant of callout', () => {
|
2018-12-17 16:17:25 -05:00
|
|
|
factory({
|
|
|
|
propsData: {
|
|
|
|
category: 'info',
|
|
|
|
message: TEST_MESSAGE,
|
|
|
|
},
|
2018-04-19 03:20:53 -04:00
|
|
|
});
|
|
|
|
|
2018-12-17 16:17:25 -05:00
|
|
|
expect(wrapper.classes()).toEqual(['bs-callout', 'bs-callout-info']);
|
2018-04-19 03:20:53 -04:00
|
|
|
|
2018-12-17 16:17:25 -05:00
|
|
|
expect(wrapper.element.tagName).toEqual('DIV');
|
2018-04-19 03:20:53 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render accessibility attributes', () => {
|
2018-12-17 16:17:25 -05:00
|
|
|
factory({
|
|
|
|
propsData: {
|
|
|
|
message: TEST_MESSAGE,
|
|
|
|
},
|
2018-04-19 03:20:53 -04:00
|
|
|
});
|
|
|
|
|
2018-12-17 16:17:25 -05:00
|
|
|
expect(wrapper.attributes('role')).toEqual('alert');
|
|
|
|
expect(wrapper.attributes('aria-live')).toEqual('assertive');
|
2018-04-19 03:20:53 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render the provided message', () => {
|
2018-12-17 16:17:25 -05:00
|
|
|
factory({
|
|
|
|
propsData: {
|
|
|
|
message: TEST_MESSAGE,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper.element.innerHTML.trim()).toEqual(TEST_MESSAGE);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render the provided slot', () => {
|
|
|
|
factory({
|
|
|
|
slots: {
|
|
|
|
default: TEST_SLOT,
|
|
|
|
},
|
2018-04-19 03:20:53 -04:00
|
|
|
});
|
|
|
|
|
2018-12-17 16:17:25 -05:00
|
|
|
expect(wrapper.element.innerHTML.trim()).toEqual(TEST_SLOT);
|
2018-04-19 03:20:53 -04:00
|
|
|
});
|
|
|
|
});
|