Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
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 Scrum Team 02
Frontend
Commits
a7132b04
Commit
a7132b04
authored
1 year ago
by
Ingrid Martinsheimen Egge
Browse files
Options
Downloads
Patches
Plain Diff
la inn tester for itemsearch
parent
1a986f6a
No related branches found
Branches containing commit
No related tags found
1 merge request
!13
Fridge view
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/__tests__/ItemSearch.spec.js
+68
-0
68 additions, 0 deletions
src/components/__tests__/ItemSearch.spec.js
with
68 additions
and
0 deletions
src/components/__tests__/ItemSearch.spec.js
0 → 100644
+
68
−
0
View file @
a7132b04
import
{
describe
,
it
,
expect
}
from
'
vitest
'
import
{
mount
}
from
'
@vue/test-utils
'
import
ItemSearch
from
"
@/components/ItemSearch.vue
"
;
const
SearchReturn
=
[
{
"
id
"
:
"
1
"
,
"
ean
"
:
"
7040512550214
"
,
"
name
"
:
"
eplekake
"
,
"
amount
"
:
{
"
quantity
"
:
"
4
"
,
"
unit
"
:
"
stk
"
},
"
image_url
"
:
"
https://bilder.ngdata.no/7040512550818/meny/large.jpg
"
},
{
"
id
"
:
"
2
"
,
"
ean
"
:
"
7040512550254
"
,
"
name
"
:
"
eple
"
,
"
amount
"
:
{
"
quantity
"
:
"
4
"
,
"
unit
"
:
"
stk
"
},
"
image_url
"
:
"
https://bilder.ngdata.no/7040512550818/meny/large.jpg
"
}];
describe
(
'
Behaves as expected
'
,
()
=>
{
it
(
'
shows correct number of results
'
,
async
()
=>
{
const
wrapper
=
mount
(
ItemSearch
,
{
data
()
{
return
{
searchResult
:
SearchReturn
,
selectedItem
:
SearchReturn
[
0
],
numOfItemsToAdd
:
3
,
};
},
});
expect
(
wrapper
.
text
()).
toContain
(
'
Resultater:
'
)
expect
(
wrapper
.
text
()).
toContain
(
'
(2)
'
)
});
it
(
'
When adding more items, the total ingredient amount is shown
'
,
async
()
=>
{
const
wrapper
=
mount
(
ItemSearch
,
{
data
()
{
return
{
searchResult
:
SearchReturn
,
selectedItem
:
SearchReturn
[
0
],
numOfItemsToAdd
:
3
,
};
},
});
// total = 3*4
const
totalItemCount
=
wrapper
.
find
(
'
span
'
)
expect
(
totalItemCount
.
text
()).
toContain
(
'
12
'
)
expect
(
totalItemCount
.
text
()).
toContain
(
'
stk
'
)
});
it
(
'
Selected contains all items
'
,
async
()
=>
{
const
wrapper
=
mount
(
ItemSearch
,
{
data
()
{
return
{
searchResult
:
SearchReturn
,
selectedItem
:
SearchReturn
[
0
],
numOfItemsToAdd
:
3
,
};
},
});
const
itemSelect
=
wrapper
.
find
(
'
select
'
)
expect
(
itemSelect
.
text
()).
toContain
(
'
eple
'
)
expect
(
itemSelect
.
text
()).
toContain
(
'
eplekake
'
)
});
})
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