Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion web-frontend/src/components/FooterContent.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<script setup>
// Required for vitest using `__name` props
const props = defineProps({});
</script>

<template>
<div class="inner">
<ul class="menu">
<li>&copy; Untitled. All rights reserved.</li><li>Design: <a href="http://html5up.net">HTML5 UP</a></li>
<li>&copy; Untitled. All rights reserved.</li>
<li>Design: <a href="http://html5up.net">HTML5 UP</a></li>
</ul>
</div>
<!-- <p class="copyright">(c) 2024 hwakabh All Right Reserved.</p> -->
Expand Down
18 changes: 18 additions & 0 deletions web-frontend/tests/FooterContent.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import FooterContent from "@/components/FooterContent.vue";
import { describe, expect, test } from "vitest";
import { shallowMount } from "@vue/test-utils";

describe("component: FooterComponent.vue", () => {
test("Component name should be correct", async () => {
expect("FooterContent").toBe(FooterContent.__name)
})
test("Component can accept value as props and render as HTML", async () => {
const expected = "© Untitled. All rights reserved.Design: HTML5 UP";
const wrapper = shallowMount(FooterContent)
// // if compoenents has props
// const wrapper = shallowMount(FooterContent, { props: {
// msg: "Hi, there!"
// }});
expect(wrapper.text()).toContain(expected);
})
Comment on lines +9 to +17
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve test readability and accuracy

Several improvements can be made to this test:

  1. Remove unnecessary async
  2. Fix spacing in expected text
  3. Consider testing the actual HTML structure instead of just text content
-  test("Component can accept value as props and render as HTML", async () => {
-    const expected = "© Untitled. All rights reserved.Design: HTML5 UP";
+  test("Component renders footer content correctly", () => {
+    const expected = "© Untitled. All rights reserved. Design: HTML5 UP";
     const wrapper = shallowMount(FooterContent)
-    // // if compoenents has props
-    // const wrapper = shallowMount(FooterContent, { props: {
-    //   msg: "Hi, there!"
-    // }});
-    expect(wrapper.text()).toContain(expected);
+    expect(wrapper.text()).toBe(expected);
+    // Consider adding structure verification
+    expect(wrapper.find('footer').exists()).toBe(true);
   })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test("Component can accept value as props and render as HTML", async () => {
const expected = "© Untitled. All rights reserved.Design: HTML5 UP";
const wrapper = shallowMount(FooterContent)
// // if compoenents has props
// const wrapper = shallowMount(FooterContent, { props: {
// msg: "Hi, there!"
// }});
expect(wrapper.text()).toContain(expected);
})
test("Component renders footer content correctly", () => {
const expected = "© Untitled. All rights reserved. Design: HTML5 UP";
const wrapper = shallowMount(FooterContent)
expect(wrapper.text()).toBe(expected);
// Consider adding structure verification
expect(wrapper.find('footer').exists()).toBe(true);
})

});
16 changes: 0 additions & 16 deletions web-frontend/tests/HelloWorld.test.js

This file was deleted.