Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
holi-app-volunteering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
app
holi-app-volunteering
Commits
069087c0
Commit
069087c0
authored
1 year ago
by
Taha Cherfia
Browse files
Options
Downloads
Patches
Plain Diff
HOLI-5486: update unit tests
parent
58f6c482
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/voltastics_test.ts
+7
-59
7 additions, 59 deletions
app/voltastics_test.ts
app/voltastics_test_data.ts
+2346
-40
2346 additions, 40 deletions
app/voltastics_test_data.ts
with
2353 additions
and
99 deletions
app/voltastics_test.ts
+
7
−
59
View file @
069087c0
...
...
@@ -13,7 +13,6 @@ import { processGqlRequest, stubFetch } from "./common_test.ts";
import
{
CategoriesResponse
,
CitiesResponse
,
Engagement
,
EngagementsResponse
,
}
from
"
./types.ts
"
;
...
...
@@ -26,17 +25,15 @@ import {
import
{
apiCategoriesResponse
,
apiCitiesResponse
,
apiSearchEngagement1
,
apiSearchEngagementsResponse
,
categories
,
cities
,
engagement1
,
engagementsResponse
,
Munich
,
}
from
"
./voltastics_test_data.ts
"
;
import
{
fetchCategories
,
fetchCities
,
fetchEngagement
,
fetchEngagements
,
}
from
"
./voltastics.ts
"
;
...
...
@@ -65,10 +62,6 @@ latitude
longitude
`
;
const
cityFragment
=
`
name
`
;
const
categoryFragment
=
`
name
`
;
...
...
@@ -79,7 +72,7 @@ const queryEngagements = async (
const
promise
=
processGqlRequest
(
graphQLServer
,
`
query engagements($limit:Int!, $offset: Int!, $location:
String!
) {
query engagements($limit:Int!, $offset: Int!, $location:
GeoJSON
) {
engagements(limit: $limit, offset: $offset, location: $location) {
totalResults
data {
...
...
@@ -87,7 +80,7 @@ const queryEngagements = async (
}
}
}`
,
{
limit
:
10
,
offset
:
20
,
l
ocation
:
"
Hamburg
"
},
{
limit
:
10
,
offset
:
20
,
l
at
:
48.1371079
,
lon
:
11.5753822
,
radius
:
14
},
);
return
(
await
promise
)?.
engagements
as
EngagementsResponse
;
...
...
@@ -110,25 +103,6 @@ const queryEngagement = async (
return
(
await
promise
)?.
engagement
as
Engagement
;
};
const
queryCities
=
async
(
graphQLServer
:
GraphQLServer
,
):
Promise
<
CitiesResponse
>
=>
{
const
promise
=
processGqlRequest
(
graphQLServer
,
`
query cities {
cities {
data {
${
cityFragment
}
}
}
}`
,
{},
);
return
(
await
promise
)?.
cities
as
CitiesResponse
;
};
const
queryCategories
=
async
(
graphQLServer
:
GraphQLServer
,
):
Promise
<
CategoriesResponse
>
=>
{
...
...
@@ -174,11 +148,11 @@ describe("voltastics", () => {
await
fetchEngagements
(
serverConfigMock
)({
limit
:
10
,
offset
:
20
,
location
:
"
Hamburg
"
,
location
:
Munich
,
});
const
expectedUrl
=
new
URL
(
"
https://test.com/api/searchengagement?limit=10&offset=20&
city=Hamburg
"
,
"
https://test.com/api/searchengagement?limit=10&offset=20&
lat=48.1371079&lon=11.5753822&radius=14
"
,
);
const
expectedHeaders
=
{
headers
:
{
"
x-voltastics-token
"
:
"
ABC123
"
}
};
...
...
@@ -209,7 +183,7 @@ describe("voltastics", () => {
const
result
=
await
fetchEngagements
(
serverConfigMock
)({
limit
:
0
,
offset
:
0
,
location
:
"
Munich
"
,
location
:
Munich
,
});
assertEquals
(
result
,
{
totalResults
:
0
,
data
:
[]
});
...
...
@@ -240,7 +214,7 @@ describe("voltastics", () => {
fetchEngagements
(
serverConfigMock
)({
limit
:
0
,
offset
:
0
,
location
:
"
Hamburg
"
,
location
:
Munich
,
})
);
});
...
...
@@ -303,32 +277,6 @@ describe("voltastics", () => {
});
});
describe
(
"
querying cities
"
,
()
=>
{
it
(
"
correctly parses cities list
"
,
async
()
=>
{
fetchStub
=
stubFetch
(
apiCitiesResponse
);
const
graphQLServer
=
createGraphQLServer
({
cacheEnabled
:
false
,
voltastics
:
voltasticsConfigMock
,
imageProxyBaseUrl
:
serverConfigMock
.
imageProxyBaseUrl
,
});
const
result
=
await
queryCities
(
graphQLServer
);
assertEquals
(
result
,
cities
);
});
it
(
"
throws error for invalid cities response
"
,
async
()
=>
{
fetchStub
=
stub
(
globalThis
,
"
fetch
"
,
returnsNext
([
Promise
.
resolve
(
new
Response
(
"
foobar
"
))]),
);
await
assertRejects
(()
=>
fetchCities
(
voltasticsConfigMock
));
});
});
describe
(
"
querying categorie
"
,
()
=>
{
it
(
"
correctly parses category list
"
,
async
()
=>
{
fetchStub
=
stubFetch
(
apiCategoriesResponse
);
...
...
This diff is collapsed.
Click to expand it.
app/voltastics_test_data.ts
+
2346
−
40
View file @
069087c0
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