I am currently working on unit testing the process of updating meta content for a Vue & Quasar page by utilizing the useMeta
component offered by Quasar.
My approach to testing this involves creating a mock Vue component called UseMetaComponent
, which is then nested within a mock App
component. Upon inspection, the UseMetaComponent
is successfully added, as indicated by the 'Component Added' message displayed in the console log when calling wrapper.html()
.
However, despite the component being added, the meta tags themselves are not being updated as expected. I have verified that this functionality does work correctly when viewed in a standard browser.
installQuasarPlugin();
const UseMetaComponent = {
name: 'UseMetaComponent',
template: `
<div>Component Added</div>
`,
setup() {
useMeta({
title: 'New Title',
meta: {
description: {
name: 'description',
content: 'test',
},
},
});
},
};
const App = {
components: {
UseMetaComponent,
},
template: `
<!DOCTYPE html>
<html>
<head>
<title>Initial Title</title>
</head>
<body>
<div id="q-app">
<use-meta-component />
</div>
</body>
</html>
`,
};
describe('QuasarMetaHandler', (): void => {
const wrapper = mount(App);
console.log(wrapper.html());
it('defaults title Site Name', (): void => {
const title = document.getElementsByTagName('title');
console.log(title);
});
});
Are there any suggestions or approaches for effectively testing the update functionality of the meta components?