Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
idatt2106_2024_02_frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IDATT2106 - Gruppe 2
idatt2106_2024_02_frontend
Commits
4e549c7f
Commit
4e549c7f
authored
11 months ago
by
Valdemar Åstorp Beere
Browse files
Options
Downloads
Patches
Plain Diff
test(component):
Created vitest for InteractiveSpare component
parent
1613b7da
No related branches found
No related tags found
3 merge requests
!66
Final merge
,
!12
feat(homepage):
,
!4
Pipeline fix
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/__tests__/InteractiveSpareTest.spec.ts
+58
-0
58 additions, 0 deletions
src/components/__tests__/InteractiveSpareTest.spec.ts
with
58 additions
and
0 deletions
src/components/__tests__/InteractiveSpareTest.spec.ts
0 → 100644
+
58
−
0
View file @
4e549c7f
import
{
describe
,
it
,
expect
}
from
'
vitest
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
SpeechBubbleComponent
from
'
@/components/InteractiveSpare.vue
'
;
// Adjust the import path as needed.
describe
(
'
SpeechBubbleComponent
'
,
()
=>
{
it
(
'
renders correctly with default props
'
,
()
=>
{
const
wrapper
=
mount
(
SpeechBubbleComponent
,
{
props
:
{
direction
:
'
left
'
,
speech
:
[
'
Hello
'
,
'
World
'
]
}
});
expect
(
wrapper
.
exists
()).
toBeTruthy
();
});
it
(
'
applies dynamic classes based on direction prop
'
,
()
=>
{
const
wrapper
=
mount
(
SpeechBubbleComponent
,
{
props
:
{
direction
:
'
right
'
,
speech
:
[
'
Hello
'
,
'
World
'
]
}
});
expect
(
wrapper
.
find
(
'
div
'
).
classes
()).
toContain
(
'
flex-row
'
);
const
wrapperReverse
=
mount
(
SpeechBubbleComponent
,
{
props
:
{
direction
:
'
left
'
,
speech
:
[
'
Hello
'
,
'
World
'
]
}
});
expect
(
wrapperReverse
.
find
(
'
div
'
).
classes
()).
toContain
(
'
flex-row-reverse
'
);
});
it
(
'
image class is computed based on direction
'
,
()
=>
{
const
wrapper
=
mount
(
SpeechBubbleComponent
,
{
props
:
{
direction
:
'
right
'
,
speech
:
[
'
Hello
'
,
'
World
'
]
}
});
expect
(
wrapper
.
find
(
'
img
'
).
classes
()).
toContain
(
'
scale-x-[-1]
'
);
});
it
(
'
updates speech text on image click
'
,
async
()
=>
{
const
wrapper
=
mount
(
SpeechBubbleComponent
,
{
props
:
{
direction
:
'
left
'
,
speech
:
[
'
First speech
'
,
'
Second speech
'
]
}
});
expect
(
wrapper
.
find
(
'
span
'
).
text
()).
toBe
(
'
First speech
'
);
await
wrapper
.
find
(
'
img
'
).
trigger
(
'
click
'
);
expect
(
wrapper
.
find
(
'
span
'
).
text
()).
toBe
(
'
Second speech
'
);
// Test wrap-around
await
wrapper
.
find
(
'
img
'
).
trigger
(
'
click
'
);
expect
(
wrapper
.
find
(
'
span
'
).
text
()).
toBe
(
'
First speech
'
);
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment