Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementPasteau committed Aug 9, 2023
1 parent 7c52386 commit f5bd4a4
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
18 changes: 14 additions & 4 deletions newIDE/app/src/UI/Search/UseSearchItem.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @flow
import { filterSearchItems, partialQuickSort } from './UseSearchItem';
import { type AssetShortHeader } from '../../Utils/GDevelopServices/Asset';
import { fakeAssetShortHeader1 } from '../../fixtures/GDevelopServicesTestData';

describe('UseSearchItem', () => {
test('sanitizeObjectName', () => {
Expand All @@ -8,11 +10,19 @@ describe('UseSearchItem', () => {

expect(filterSearchItems(null, null, new Set())).toEqual(null);

const items = [{ id: 1, tags: ['hello'] }, { id: 2, tags: ['world'] }];
const item1: AssetShortHeader = {
...fakeAssetShortHeader1,
id: '1',
tags: ['hello'],
};
const item2: AssetShortHeader = {
...fakeAssetShortHeader1,
id: '2',
tags: ['world'],
};
const items = [item1, item2];
expect(filterSearchItems(items, null, new Set())).toEqual(items);
expect(filterSearchItems(items, null, new Set(['world']))).toEqual([
{ id: 2, tags: ['world'] },
]);
expect(filterSearchItems(items, null, new Set(['world']))).toEqual([item2]);
});
});

Expand Down
26 changes: 26 additions & 0 deletions newIDE/app/src/fixtures/GDevelopServicesTestData/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,8 @@ export const fakeAssetPacks: PublicAssetPacks = {
thumbnailUrl:
'https://resources.gdevelop-app.com/assets/Packs/platformer.png',
assetsCount: 16,
authors: [],
licenses: [],
},
{
name: 'Space Shooter',
Expand All @@ -1561,6 +1563,8 @@ export const fakeAssetPacks: PublicAssetPacks = {
thumbnailUrl:
'https://resources.gdevelop-app.com/assets/Packs/space shooter.png',
assetsCount: 140,
authors: [],
licenses: [],
},
{
name: 'Tanks',
Expand All @@ -1569,6 +1573,8 @@ export const fakeAssetPacks: PublicAssetPacks = {
thumbnailUrl:
'https://resources.gdevelop-app.com/assets/Packs/tank pack.png',
assetsCount: 32,
authors: [],
licenses: [],
},
{
name: 'Pixel Adventure',
Expand All @@ -1577,6 +1583,8 @@ export const fakeAssetPacks: PublicAssetPacks = {
thumbnailUrl:
'https://resources.gdevelop-app.com/assets/Packs/pixel adventure pack.png',
assetsCount: 80,
authors: [],
licenses: [],
},
{
name: 'Fake Paid External',
Expand All @@ -1585,6 +1593,8 @@ export const fakeAssetPacks: PublicAssetPacks = {
thumbnailUrl:
'https://resources.gdevelop-app.com/assets/Packs/pirate bomb pack.png',
assetsCount: 48,
authors: [],
licenses: [],
externalWebLink: 'https://example.com',
userFriendlyPrice: '$4.99',
},
Expand All @@ -1595,13 +1605,17 @@ export const fakeAssetPacks: PublicAssetPacks = {
thumbnailUrl:
'https://resources.gdevelop-app.com/assets/Packs/pixel effects pack.png',
assetsCount: 20,
authors: [],
licenses: [],
},
{
name: 'Emotes',
tag: 'emote',
categories: [],
thumbnailUrl: 'https://resources.gdevelop-app.com/assets/Packs/emote.png',
assetsCount: 176,
authors: [],
licenses: [],
},
{
name: 'Dinosaurus Characters',
Expand All @@ -1610,6 +1624,8 @@ export const fakeAssetPacks: PublicAssetPacks = {
thumbnailUrl:
'https://resources.gdevelop-app.com/assets/Packs/24x24 dino characters.png',
assetsCount: 5,
authors: [],
licenses: [],
},
{
name: 'Fake Paid Spinning Items',
Expand All @@ -1618,6 +1634,8 @@ export const fakeAssetPacks: PublicAssetPacks = {
thumbnailUrl:
'https://resources.gdevelop-app.com/assets/Packs/16x16 pixel art spinning items.png',
assetsCount: 30,
authors: [],
licenses: [],
userFriendlyPrice: '$4.99',
},
{
Expand All @@ -1627,6 +1645,8 @@ export const fakeAssetPacks: PublicAssetPacks = {
thumbnailUrl:
'https://resources.gdevelop-app.com/assets/Packs/16x16 pixel art rpg items.png',
assetsCount: 64,
authors: [],
licenses: [],
},
{
name: 'RPG Items',
Expand All @@ -1635,6 +1655,8 @@ export const fakeAssetPacks: PublicAssetPacks = {
thumbnailUrl:
'https://resources.gdevelop-app.com/assets/Packs/16x16 rpg item pack.png',
assetsCount: 144,
authors: [],
licenses: [],
},
{
name: 'Fantasy Icons',
Expand All @@ -1643,6 +1665,8 @@ export const fakeAssetPacks: PublicAssetPacks = {
thumbnailUrl:
'https://resources.gdevelop-app.com/assets/Packs/32x32 fantasy icons pack v2.png',
assetsCount: 285,
authors: [],
licenses: [],
},
{
name: 'On-Screen Controls',
Expand All @@ -1651,6 +1675,8 @@ export const fakeAssetPacks: PublicAssetPacks = {
thumbnailUrl:
'https://resources.gdevelop-app.com/assets/Packs/on-screen controls.png',
assetsCount: 287,
authors: [],
licenses: [],
},
],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const PublicAsset = () => {
onTagSelection={() => {}}
assetShortHeader={fakeAssetShortHeader1}
onOpenDetails={assetShortHeader => {}}
onPrivateAssetPackSelection={() => {}}
/>
</AssetStoreStateProvider>
);
Expand All @@ -51,6 +52,7 @@ export const PrivateAsset = () => (
onTagSelection={() => {}}
assetShortHeader={fakeAssetShortHeader1}
onOpenDetails={assetShortHeader => {}}
onPrivateAssetPackSelection={() => {}}
/>
</AssetStoreStateProvider>
</PublicProfileProvider>
Expand Down Expand Up @@ -105,6 +107,7 @@ export const AssetWithMultipleAuthors = () => (
onTagSelection={() => {}}
assetShortHeader={fakeAssetShortHeader1}
onOpenDetails={assetShortHeader => {}}
onPrivateAssetPackSelection={() => {}}
/>
</AssetStoreStateProvider>
</PublicProfileProvider>
Expand Down

0 comments on commit f5bd4a4

Please sign in to comment.