Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
boco-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
Container 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_2022_02
boco-frontend
Commits
c4037e5c
Commit
c4037e5c
authored
2 years ago
by
Titus Netland
Browse files
Options
Downloads
Plain Diff
Merge branch 'image-tests' into 'main'
api tests for image methods See merge request
!126
parents
1c392236
5516181f
No related branches found
Branches containing commit
No related tags found
1 merge request
!126
api tests for image methods
Pipeline
#181634
failed
2 years ago
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/unit/api-mock-tests/apiutil-image-mock.spec.js
+38
-0
38 additions, 0 deletions
tests/unit/api-mock-tests/apiutil-image-mock.spec.js
with
38 additions
and
0 deletions
tests/unit/api-mock-tests/apiutil-image-mock.spec.js
0 → 100644
+
38
−
0
View file @
c4037e5c
import
{
postNewImageCommunity
,
PostImagesArrayToListing
}
from
"
@/utils/apiutil
"
;
import
axios
from
"
axios
"
;
jest
.
mock
(
"
axios
"
);
describe
(
"
testing mocking of apiutil.js image api calls
"
,
()
=>
{
it
(
"
check that image gets posted
"
,
async
()
=>
{
let
expectedResponse
=
1
;
axios
.
post
.
mockImplementation
(()
=>
Promise
.
resolve
({
data
:
expectedResponse
})
);
const
imageResponse
=
await
postNewImageCommunity
(
"
image
"
);
expect
(
imageResponse
).
toBe
(
expectedResponse
);
});
it
(
"
check that image array gets posted to listing
"
,
async
()
=>
{
let
expectedResponse
=
"
OK
"
;
const
imageArray
=
{
image1
:
{
image
:
"
image1
"
},
image2
:
{
image2
:
"
image2
"
},
};
axios
.
post
.
mockImplementation
(()
=>
Promise
.
resolve
({
data
:
expectedResponse
})
);
const
imageResponse
=
await
PostImagesArrayToListing
(
imageArray
);
expect
(
imageResponse
.
data
).
toBe
(
expectedResponse
);
});
});
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