summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSukanya Pandey <sukapan1@in.ibm.com>2020-12-02 17:00:45 +0300
committerYoshie Muranaka <yoshiemuranaka@gmail.com>2020-12-02 22:47:51 +0300
commite6693048f6e2d069ac27a73c93fc7faf51eae5de (patch)
treedd485d867c1ca5e6765efeeea2cff32007959fef /tests
parent11bafca85ee2c3f4d4fac5f2ea6b874059099211 (diff)
downloadwebui-vue-e6693048f6e2d069ac27a73c93fc7faf51eae5de.tar.xz
Add unit testing for page title component
Signed-off-by: Sukanya Pandey <sukapan1@in.ibm.com> Change-Id: I1fc54f54bd8e9a7d132eab0edaed94a4032143c8
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/Global/PageTitle.spec.js33
-rw-r--r--tests/unit/Global/__snapshots__/PageTitle.spec.js.snap15
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/unit/Global/PageTitle.spec.js b/tests/unit/Global/PageTitle.spec.js
new file mode 100644
index 00000000..5cb2691b
--- /dev/null
+++ b/tests/unit/Global/PageTitle.spec.js
@@ -0,0 +1,33 @@
+import { mount, createLocalVue } from '@vue/test-utils';
+import PageTitle from '@/components/Global/PageTitle';
+
+const localVue = createLocalVue();
+
+describe('PageTitle.vue', () => {
+ const wrapper = mount(PageTitle, {
+ localVue,
+ propsData: {
+ description: 'A page title test description',
+ },
+ mocks: {
+ $t: (key) => key,
+ $route: {
+ meta: {
+ title: 'Page Title',
+ },
+ },
+ },
+ });
+ it('should exist', () => {
+ expect(wrapper.exists()).toBe(true);
+ });
+ it('should render h1 element', () => {
+ expect(wrapper.find('h1').exists()).toBe(true);
+ });
+ it('should render p element', () => {
+ expect(wrapper.find('p').exists()).toBe(true);
+ });
+ it('should render correctly', () => {
+ expect(wrapper.element).toMatchSnapshot();
+ });
+});
diff --git a/tests/unit/Global/__snapshots__/PageTitle.spec.js.snap b/tests/unit/Global/__snapshots__/PageTitle.spec.js.snap
new file mode 100644
index 00000000..7c1bca74
--- /dev/null
+++ b/tests/unit/Global/__snapshots__/PageTitle.spec.js.snap
@@ -0,0 +1,15 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`PageTitle.vue should render correctly 1`] = `
+<div
+ class="page-title"
+>
+ <h1>
+ Page Title
+ </h1>
+
+ <p>
+ A page title test description
+ </p>
+</div>
+`;