Skip to content

Commit edc1f28

Browse files
Update tests
1 parent 304450f commit edc1f28

File tree

4 files changed

+137
-26
lines changed

4 files changed

+137
-26
lines changed

__tests__/post-build/__snapshots__/exampleShortHeaders.json.spec.js.snap

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,94 @@ Get as far as you can before you crash in to a wall, submit your score, and try
132132
],
133133
}
134134
`;
135+
136+
exports[`exampleShortHeaders.json post build checks defaultTags 3`] = `
137+
Object {
138+
"authorIds": Array [],
139+
"codeSizeLevel": "tiny",
140+
"description": "",
141+
"gdevelopVersion": "",
142+
"id": "0c9a01cf4f401ce3df54cdbc9168ba652b3b43265b3dcbbed754599247165e5a",
143+
"license": "MIT",
144+
"linkedExampleShortHeaders": Array [
145+
Object {
146+
"relation": "pixel-art-version",
147+
"slug": "starting-platformer-pixel",
148+
},
149+
],
150+
"name": "Platformer",
151+
"previewImageUrls": Array [
152+
"https://resources.gdevelop-app.com/examples/starting-platformer/preview.png",
153+
],
154+
"shortDescription": "Starting point for a platformer game.",
155+
"slug": "starting-platformer",
156+
"tags": Array [
157+
"starting-platformer",
158+
"Starting point",
159+
"Animatable capability",
160+
"Sounds and music",
161+
"Mathematical tools",
162+
"Objects",
163+
"Variables",
164+
"Debugger Tools",
165+
"Effect capability",
166+
"Flippable capability",
167+
"Opacity capability",
168+
"Platform behavior",
169+
"Resizable capability",
170+
"Scalable capability",
171+
"Sprite",
172+
"Tiled Sprite Object",
173+
"Tweening",
174+
"Button states and effects",
175+
"Multitouch joystick and buttons (sprite)",
176+
"Smooth Camera",
177+
],
178+
}
179+
`;
180+
181+
exports[`exampleShortHeaders.json post build checks defaultTags 4`] = `
182+
Object {
183+
"authorIds": Array [],
184+
"codeSizeLevel": "tiny",
185+
"description": "",
186+
"gdevelopVersion": "",
187+
"id": "986ba30910cf3873205796d8331f76dee507673d89e55b04415759cd39b2ebca",
188+
"license": "MIT",
189+
"linkedExampleShortHeaders": Array [
190+
Object {
191+
"relation": "non-pixel-art-version",
192+
"slug": "starting-platformer",
193+
},
194+
],
195+
"name": "Platformer (Pixel Art)",
196+
"previewImageUrls": Array [
197+
"https://resources.gdevelop-app.com/examples/starting-platformer-pixel/preview.png",
198+
],
199+
"shortDescription": "Starting point for a platformer game, optimized for pixel art.",
200+
"slug": "starting-platformer-pixel",
201+
"tags": Array [
202+
"starting-platformer-pixel",
203+
"Animatable capability",
204+
"Sounds and music",
205+
"Layers and cameras",
206+
"Mathematical tools",
207+
"Objects",
208+
"Scene",
209+
"Variables",
210+
"Debugger Tools",
211+
"Effect capability",
212+
"Flippable capability",
213+
"Opacity capability",
214+
"Platform behavior",
215+
"Resizable capability",
216+
"Scalable capability",
217+
"Sprite",
218+
"Tiled Sprite Object",
219+
"Tweening",
220+
"Button states and effects",
221+
"Multitouch joystick and buttons (sprite)",
222+
"Smooth Camera",
223+
],
224+
}
225+
`;

__tests__/post-build/exampleShortHeaders.json.spec.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,39 @@ describe('exampleShortHeaders.json post build checks', () => {
2121
expect(exampleShortHeaders.length).toBeGreaterThan(120);
2222

2323
const platformer = exampleShortHeaders.find(
24-
({ name }) => name === 'Platformer'
24+
({ slug }) => slug === 'platformer'
2525
);
2626
if (!platformer)
2727
throw new Error('Platformer not found in the example short headers');
2828

2929
expect(platformer).toMatchSnapshot();
3030

3131
const tappyPlane = exampleShortHeaders.find(
32-
({ name }) => name === 'Tappy plane'
32+
({ slug }) => slug === 'tappy-plane'
3333
);
3434
if (!tappyPlane)
3535
throw new Error('Tappy Plane not found in the example short headers');
3636

3737
expect(tappyPlane).toMatchSnapshot();
38+
39+
const startingPointPlatformer = exampleShortHeaders.find(
40+
({ slug }) => slug === 'starting-platformer'
41+
);
42+
if (!startingPointPlatformer)
43+
throw new Error(
44+
'Starting Point Platformer not found in the example short headers'
45+
);
46+
47+
expect(startingPointPlatformer).toMatchSnapshot();
48+
49+
const startingPointPixelPlatformer = exampleShortHeaders.find(
50+
({ slug }) => slug === 'starting-platformer-pixel'
51+
);
52+
if (!startingPointPixelPlatformer)
53+
throw new Error(
54+
'Starting Point Pixel Platformer not found in the example short headers'
55+
);
56+
57+
expect(startingPointPixelPlatformer).toMatchSnapshot();
3858
});
3959
});

scripts/generate-database.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -217,17 +217,17 @@ const sortedStarterSlugs = new Set([
217217
const sortedStartingPointConfigs = [
218218
{
219219
slug: 'starting-platformer',
220-
pixelArtSlug: 'pixel-art-starting-platformer',
220+
pixelArtSlug: 'starting-platformer-pixel',
221221
title: 'Platformer',
222222
},
223223
{
224224
slug: 'starting-top-down',
225-
pixelArtSlug: 'pixel-art-starting-top-down',
225+
pixelArtSlug: 'starting-top-down-pixel',
226226
title: 'Top-down',
227227
},
228228
{
229229
slug: 'starting-physics',
230-
pixelArtSlug: 'pixel-art-starting-physics',
230+
pixelArtSlug: 'starting-physics-pixel',
231231
title: 'Physics',
232232
},
233233
{ slug: 'starting-3D-platformer', title: '3D Platformer' },
@@ -248,10 +248,6 @@ const sortedStartingPointPixelArtSlugs = new Set(
248248
* @returns {ExampleShortHeader}
249249
*/
250250
const adaptAndAddLinkedExampleShortHeaders = (exampleShortHeader) => {
251-
if (!sortedStartingPointSlugs.has(exampleShortHeader.slug)) {
252-
return exampleShortHeader;
253-
}
254-
255251
if (sortedStartingPointPixelArtSlugs.has(exampleShortHeader.slug)) {
256252
const config = sortedStartingPointConfigs.find(
257253
(config) => config.pixelArtSlug === exampleShortHeader.slug
@@ -269,24 +265,28 @@ const adaptAndAddLinkedExampleShortHeaders = (exampleShortHeader) => {
269265
};
270266
}
271267

272-
const config = sortedStartingPointConfigs.find(
273-
(config) => config.slug === exampleShortHeader.slug
274-
);
275-
if (!config) return exampleShortHeader;
268+
if (sortedStartingPointSlugs.has(exampleShortHeader.slug)) {
269+
const config = sortedStartingPointConfigs.find(
270+
(config) => config.slug === exampleShortHeader.slug
271+
);
272+
if (!config) return exampleShortHeader;
276273

277-
return {
278-
...exampleShortHeader,
279-
// Update title for a friendly one.
280-
name: config.title,
281-
linkedExampleShortHeaders: config.pixelArtSlug
282-
? [
283-
{
284-
slug: config.pixelArtSlug,
285-
relation: 'pixel-art-version',
286-
},
287-
]
288-
: [],
289-
};
274+
return {
275+
...exampleShortHeader,
276+
// Update title for a friendly one.
277+
name: config.title,
278+
linkedExampleShortHeaders: config.pixelArtSlug
279+
? [
280+
{
281+
slug: config.pixelArtSlug,
282+
relation: 'pixel-art-version',
283+
},
284+
]
285+
: [],
286+
};
287+
}
288+
289+
return exampleShortHeader;
290290
};
291291

292292
/**

0 commit comments

Comments
 (0)