2023-05-27 22:25:52 +05:30
|
|
|
import { nextTick } from 'vue';
|
|
|
|
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
|
2022-07-16 23:28:13 +05:30
|
|
|
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
|
2023-05-27 22:25:52 +05:30
|
|
|
import Title from '~/issues/show/components/title.vue';
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
describe('Title component', () => {
|
2023-05-27 22:25:52 +05:30
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
const getTitleHeader = () => wrapper.findByTestId('issue-title');
|
|
|
|
|
|
|
|
const createWrapper = (props) => {
|
2022-07-16 23:28:13 +05:30
|
|
|
setHTMLFixture(`<title />`);
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
wrapper = shallowMountExtended(Title, {
|
2017-09-10 17:25:29 +05:30
|
|
|
propsData: {
|
|
|
|
issuableRef: '#1',
|
|
|
|
titleHtml: 'Testing <img />',
|
|
|
|
titleText: 'Testing',
|
2023-05-27 22:25:52 +05:30
|
|
|
...props,
|
2017-09-10 17:25:29 +05:30
|
|
|
},
|
2023-05-27 22:25:52 +05:30
|
|
|
});
|
|
|
|
};
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
afterEach(() => {
|
|
|
|
resetHTMLFixture();
|
|
|
|
});
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
it('renders title HTML', () => {
|
2023-05-27 22:25:52 +05:30
|
|
|
createWrapper();
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(getTitleHeader().element.innerHTML.trim()).toBe('Testing <img>');
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
it('animates title changes', async () => {
|
2023-05-27 22:25:52 +05:30
|
|
|
createWrapper();
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
await wrapper.setProps({
|
|
|
|
titleHtml: 'test',
|
|
|
|
});
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(getTitleHeader().classes('issue-realtime-pre-pulse')).toBe(true);
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
jest.runAllTimers();
|
2022-04-04 11:22:00 +05:30
|
|
|
await nextTick();
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(getTitleHeader().classes('issue-realtime-trigger-pulse')).toBe(true);
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
it('updates page title after changing title', async () => {
|
2023-05-27 22:25:52 +05:30
|
|
|
createWrapper();
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
await wrapper.setProps({
|
|
|
|
titleHtml: 'changed',
|
|
|
|
titleText: 'changed',
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(document.querySelector('title').textContent.trim()).toContain('changed');
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|