Skip to content

Commit c8b8c8e

Browse files
committed
feat: Add utils tests
1 parent f838c0f commit c8b8c8e

File tree

2 files changed

+86
-4
lines changed

2 files changed

+86
-4
lines changed

Diff for: src/entities/Map/routes/getAllPlacesList.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ test("should return a list of places with no query", async () => {
4747
},
4848
{
4949
...allPlacesWithAggregatedAttributes[1],
50-
user_count: worldsLiveData.totalUsers,
50+
user_count: worldsLiveData.perWorld[0].users,
5151
// TODO: Get user visits from world stats
5252
user_visits: 0,
5353
},
@@ -115,7 +115,7 @@ test("should return a list of places with order by most_active", async () => {
115115
data: [
116116
{
117117
...allPlacesWithAggregatedAttributes[1],
118-
user_count: worldsLiveData.totalUsers,
118+
user_count: worldsLiveData.perWorld[0].users,
119119
// TODO: Get user visits from world stats
120120
user_visits: 0,
121121
},
@@ -158,7 +158,7 @@ test("should return a list of places with Realm details", async () => {
158158
},
159159
{
160160
...allPlacesWithAggregatedAttributes[1],
161-
user_count: worldsLiveData.totalUsers,
161+
user_count: worldsLiveData.perWorld[0].users,
162162
// TODO: Get user visits from world stats
163163
user_visits: 0,
164164
},

Diff for: src/entities/Map/utils.test.ts

+83-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
import { allPlacesWithAggregatedAttributes } from "../../__data__/allPlacesWithAggregatedAttributes"
12
import { hotSceneGenesisPlaza } from "../../__data__/hotSceneGenesisPlaza"
23
import { placeGenesisPlazaWithAggregatedAttributes } from "../../__data__/placeGenesisPlazaWithAggregatedAttributes"
34
import { sceneStatsGenesisPlaza } from "../../__data__/sceneStatsGenesisPlaza"
4-
import { placesWithCoordinatesAggregates } from "./utils"
5+
import { worldsLiveData } from "../../__data__/worldsLiveData"
6+
import {
7+
allPlacesWithAggregates,
8+
placesWithCoordinatesAggregates,
9+
} from "./utils"
510

611
describe("get of AggregatePlaceAttributes", () => {
712
test("should return a place of type AggregateCoordinatePlaceAttributes", () => {
@@ -67,3 +72,80 @@ describe("get of AggregatePlaceAttributes", () => {
6772
})
6873
})
6974
})
75+
76+
describe("get of AllPlacesWithAggregates", () => {
77+
test("should return a place of type AggregateCoordinatePlaceAttributes", () => {
78+
const places = allPlacesWithAggregates(
79+
allPlacesWithAggregatedAttributes,
80+
[hotSceneGenesisPlaza],
81+
sceneStatsGenesisPlaza,
82+
worldsLiveData
83+
)
84+
expect(places).toEqual([
85+
{
86+
...allPlacesWithAggregatedAttributes[0],
87+
user_count: hotSceneGenesisPlaza.usersTotalCount,
88+
user_visits:
89+
sceneStatsGenesisPlaza[
90+
allPlacesWithAggregatedAttributes[0].base_position
91+
].last_30d.users,
92+
},
93+
{
94+
...allPlacesWithAggregatedAttributes[1],
95+
user_count: worldsLiveData.perWorld[0].users,
96+
// TODO: Get user visits from world stats
97+
user_visits: 0,
98+
},
99+
])
100+
})
101+
102+
test("should return a place of type AggregatePlaceAttributes with user_visits when not match the base position", () => {
103+
const place = {
104+
...allPlacesWithAggregatedAttributes[0],
105+
base_position: "-1,-1",
106+
}
107+
const places = allPlacesWithAggregates(
108+
[place],
109+
[hotSceneGenesisPlaza],
110+
sceneStatsGenesisPlaza,
111+
worldsLiveData
112+
)
113+
expect(places).toEqual([
114+
{
115+
...place,
116+
user_count: hotSceneGenesisPlaza.usersTotalCount,
117+
user_visits:
118+
sceneStatsGenesisPlaza[
119+
allPlacesWithAggregatedAttributes[0].base_position
120+
].last_30d.users,
121+
},
122+
])
123+
})
124+
125+
test("should return a place of type AggregatePlaceAttributes with realm details", () => {
126+
const places = allPlacesWithAggregates(
127+
allPlacesWithAggregatedAttributes,
128+
[hotSceneGenesisPlaza],
129+
sceneStatsGenesisPlaza,
130+
worldsLiveData,
131+
{ withRealmsDetail: true }
132+
)
133+
expect(places).toEqual([
134+
{
135+
...allPlacesWithAggregatedAttributes[0],
136+
user_count: hotSceneGenesisPlaza.usersTotalCount,
137+
user_visits:
138+
sceneStatsGenesisPlaza[
139+
allPlacesWithAggregatedAttributes[0].base_position
140+
].last_30d.users,
141+
realms_detail: hotSceneGenesisPlaza.realms,
142+
},
143+
{
144+
...allPlacesWithAggregatedAttributes[1],
145+
user_count: worldsLiveData.perWorld[0].users,
146+
// TODO: Get user visits from world stats
147+
user_visits: 0,
148+
},
149+
])
150+
})
151+
})

0 commit comments

Comments
 (0)