2020-03-13 15:44:24 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2020-01-01 13:55:28 +05:30
|
|
|
import ReplyPlaceholder from '~/notes/components/discussion_reply_placeholder.vue';
|
2019-03-02 22:35:43 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
const placeholderText = 'Test Button Text';
|
2019-03-02 22:35:43 +05:30
|
|
|
|
|
|
|
describe('ReplyPlaceholder', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
const createComponent = ({ options = {} } = {}) => {
|
2019-03-02 22:35:43 +05:30
|
|
|
wrapper = shallowMount(ReplyPlaceholder, {
|
2019-09-30 21:07:59 +05:30
|
|
|
propsData: {
|
2021-04-17 20:07:23 +05:30
|
|
|
placeholderText,
|
2019-09-30 21:07:59 +05:30
|
|
|
},
|
2021-09-04 01:27:46 +05:30
|
|
|
...options,
|
2019-03-02 22:35:43 +05:30
|
|
|
});
|
2021-09-04 01:27:46 +05:30
|
|
|
};
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
const findTextarea = () => wrapper.findComponent({ ref: 'textarea' });
|
2019-03-02 22:35:43 +05:30
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
it('emits focus event on button click', async () => {
|
|
|
|
createComponent({ options: { attachTo: document.body } });
|
|
|
|
|
|
|
|
await findTextarea().trigger('focus');
|
2019-03-02 22:35:43 +05:30
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
expect(wrapper.emitted()).toEqual({
|
|
|
|
focus: [[]],
|
2019-03-02 22:35:43 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render reply button', () => {
|
2021-09-04 01:27:46 +05:30
|
|
|
createComponent();
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
expect(findTextarea().attributes('placeholder')).toEqual(placeholderText);
|
2019-03-02 22:35:43 +05:30
|
|
|
});
|
|
|
|
});
|