From f60abe9aad631d9e69b677ca47106daa22342b40 Mon Sep 17 00:00:00 2001
From: Souma <101255979+5ouma@users.noreply.github.com>
Date: Fri, 8 Nov 2024 23:15:38 +0900
Subject: [PATCH] test(component): Add more test cases for anomalous conditions
(#10)
Some conditions must cause errors.
---
src/components/Bio/Bio.test.ts | 1 +
src/components/Contact/Contact.test.ts | 39 ++++++++++++++++++----
src/components/Homepage/Homepage.test.ts | 41 ++++++++++++++++--------
src/libs/contact.ts | 24 +++++++++++---
4 files changed, 80 insertions(+), 25 deletions(-)
diff --git a/src/components/Bio/Bio.test.ts b/src/components/Bio/Bio.test.ts
index 48aac20..341df0b 100644
--- a/src/components/Bio/Bio.test.ts
+++ b/src/components/Bio/Bio.test.ts
@@ -13,6 +13,7 @@ describe("Bio", () => {
expect(result).toContain(`>${props.name}`);
expect(result).toContain(`>${props.description}`);
expect(result).toContain(` {
- for (const [name, props] of Object.entries(stories)) {
- test(name, async () => {
- const container: AstroContainer = await AstroContainer.create();
- const result: string = await container.renderToString(Contact, { props });
+ describe("Valid service and ID", () => {
+ for (const [name, props] of Object.entries(stories)) {
+ test(name, async () => {
+ const container: AstroContainer = await AstroContainer.create();
+ const result: string = await container.renderToString(Contact, {
+ props,
+ });
- expect(result).toContain(`>${props.id}`);
- });
- }
+ expect(result).toContain(`>${props.id}`);
+ expect(result).toMatch(new RegExp(`href=["'].*${props.id}["']`));
+ expect(result).toContain('