Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<a href="https://github.com/LizardByte/GameDB/actions/workflows/ci-tests.yml?query=branch%3Amaster"><img src="https://img.shields.io/github/actions/workflow/status/lizardbyte/gamedb/ci-tests.yml.svg?branch=master&label=CI&logo=github&style=for-the-badge" alt="CI"></a>
<a href="https://github.com/LizardByte/GameDB/actions/workflows/update-db.yml?query=branch%3Amaster"><img src="https://img.shields.io/github/actions/workflow/status/lizardbyte/gamedb/update-db.yml.svg?branch=master&label=update%20db&logo=github&style=for-the-badge" alt="Update DB"></a>
<a href="https://app.codecov.io/gh/LizardByte/GameDB"><img src="https://img.shields.io/codecov/c/gh/LizardByte/GameDB.svg?token=AG91ICECDX&style=for-the-badge&logo=codecov&label=codecov" alt="Codecov"></a>
<a href="https://sonarcloud.io/project/overview?id=LizardByte_GameDB"><img src="https://img.shields.io/sonar/quality_gate/LizardByte_GameDB?server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge&logo=sonarqubecloud&label=sonarcloud" alt="SonarCloud"></a>
</div>

---
Expand Down
2 changes: 1 addition & 1 deletion tests/character_detail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('character_detail.js', () => {

test('skips badges when gender and species absent', () => {
renderCharacter({ name: 'Robot' });
expect(document.getElementById('character-badges').children.length).toBe(0);
expect(document.getElementById('character-badges').children).toHaveLength(0);
});

test('shows games section when games present', () => {
Expand Down
32 changes: 16 additions & 16 deletions tests/game_detail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ describe('game_detail.js', () => {
game_modes: [{ name: 'Single player' }],
player_perspectives: [{ name: 'First person' }],
});
expect(document.getElementById('game-badges').children.length).toBe(4);
expect(document.getElementById('game-badges').children).toHaveLength(4);
});

test('handles missing badge arrays gracefully', () => {
renderGameBadges({});
expect(document.getElementById('game-badges').children.length).toBe(0);
expect(document.getElementById('game-badges').children).toHaveLength(0);
});
});

Expand All @@ -136,15 +136,15 @@ describe('game_detail.js', () => {
test('skips when no ratings', () => {
const dl = document.getElementById('game-meta');
renderGameRatings({}, dl);
expect(dl.children.length).toBe(0);
expect(dl.children).toHaveLength(0);
});

test('skips age ratings row when all entries are incomplete', () => {
const dl = document.getElementById('game-meta');
renderGameRatings({
age_ratings: [{ rating_category: null, organization: null }],
}, dl);
expect(dl.children.length).toBe(0);
expect(dl.children).toHaveLength(0);
});
});

Expand Down Expand Up @@ -174,7 +174,7 @@ describe('game_detail.js', () => {
test('skips when no platforms', () => {
const dl = document.getElementById('game-meta');
renderGamePlatforms({}, dl);
expect(dl.children.length).toBe(0);
expect(dl.children).toHaveLength(0);
});
});

Expand All @@ -195,13 +195,13 @@ describe('game_detail.js', () => {
test('skips when no release dates', () => {
const dl = document.getElementById('game-meta');
renderReleaseDates({}, dl);
expect(dl.children.length).toBe(0);
expect(dl.children).toHaveLength(0);
});

test('skips row when all entries lack date and y', () => {
const dl = document.getElementById('game-meta');
renderReleaseDates({ release_dates: [{ date: null, y: null }] }, dl);
expect(dl.children.length).toBe(0);
expect(dl.children).toHaveLength(0);
});

test('renders release date with unknown release_region (empty flag)', () => {
Expand Down Expand Up @@ -239,13 +239,13 @@ describe('game_detail.js', () => {
test('skips when no involved companies', () => {
const dl = document.getElementById('game-meta');
renderCompanies({}, dl);
expect(dl.children.length).toBe(0);
expect(dl.children).toHaveLength(0);
});

test('skips rows when devs or pubs list is empty', () => {
const dl = document.getElementById('game-meta');
renderCompanies({ involved_companies: [] }, dl);
expect(dl.children.length).toBe(0);
expect(dl.children).toHaveLength(0);
});
});

Expand Down Expand Up @@ -302,7 +302,7 @@ describe('game_detail.js', () => {
test('skips franchise when neither franchises array nor franchise object', () => {
const dl = document.getElementById('game-meta');
renderCollectionsAndFranchises({}, dl);
expect(dl.children.length).toBe(0);
expect(dl.children).toHaveLength(0);
});
});

Expand All @@ -318,13 +318,13 @@ describe('game_detail.js', () => {
test('skips when no multiplayer modes', () => {
const dl = document.getElementById('game-meta');
renderMultiplayer({}, dl);
expect(dl.children.length).toBe(0);
expect(dl.children).toHaveLength(0);
});

test('skips when parts are empty', () => {
const dl = document.getElementById('game-meta');
renderMultiplayer({ multiplayer_modes: [{}] }, dl);
expect(dl.children.length).toBe(0);
expect(dl.children).toHaveLength(0);
});
});

Expand All @@ -339,7 +339,7 @@ describe('game_detail.js', () => {
const section = document.getElementById('game-screenshots-section');
expect(section.classList.contains('d-none')).toBe(false);
const buttons = document.querySelectorAll('#game-screenshots button');
expect(buttons.length).toBe(2);
expect(buttons).toHaveLength(2);
buttons[0].click();
expect(globalThis.openImageModal).toHaveBeenCalled();
});
Expand All @@ -365,7 +365,7 @@ describe('game_detail.js', () => {

test('skips video entries without video_id', () => {
renderVideos({ videos: [{ name: 'No ID' }] });
expect(document.querySelectorAll('#game-videos iframe').length).toBe(0);
expect(document.querySelectorAll('#game-videos iframe')).toHaveLength(0);
});

test('skips when no videos', () => {
Expand Down Expand Up @@ -406,7 +406,7 @@ describe('game_detail.js', () => {

test('skips entries with no url and no uid', () => {
renderExternalLinks({ external_games: [{}] });
expect(document.getElementById('game-external').children.length).toBe(0);
expect(document.getElementById('game-external').children).toHaveLength(0);
});

test('skips when no external_games', () => {
Expand Down Expand Up @@ -509,7 +509,7 @@ describe('game_detail.js', () => {
introHeader.appendChild(existingDesc);
// Should not add a second img-desc
setupGameBanner({ artworks: [{ url: '//images.igdb.com/t_thumb/art.jpg' }] });
expect(document.querySelectorAll('.intro-header .img-desc').length).toBe(1);
expect(document.querySelectorAll('.intro-header .img-desc')).toHaveLength(1);
});

test('does not throw when artworks present but no .page-heading anywhere', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/item_detail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ describe('item_detail.js', () => {
test('appends dt and dd with string value', () => {
const dl = document.createElement('dl');
addDlRow(dl, 'Developer', 'Test Studio');
expect(dl.children.length).toBe(2);
expect(dl.children).toHaveLength(2);
expect(dl.children[0].tagName).toBe('DT');
expect(dl.children[1].tagName).toBe('DD');
expect(dl.children[0].textContent).toBe('Developer');
Expand Down
14 changes: 7 additions & 7 deletions tests/item_loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('item_loader.js', () => {
test('splits at word boundary when longer than 200 chars', () => {
const long = 'word '.repeat(50); // 250 chars
const result = splitString(long);
expect(result.length).toBe(2);
expect(result).toHaveLength(2);
expect(result[0].length).toBeLessThanOrEqual(200);
expect(result[1]).toBe(long);
});
Expand Down Expand Up @@ -137,7 +137,7 @@ describe('item_loader.js', () => {
}, allPlatforms);
// Should show first 3 platforms + "+1 more"
const badges = col.querySelectorAll('.badge');
expect(badges.length).toBe(4); // 3 platforms + "+1 more"
expect(badges).toHaveLength(4); // 3 platforms + "+1 more"
expect(col.textContent).toContain('+1 more');
});

Expand Down Expand Up @@ -167,22 +167,22 @@ describe('item_loader.js', () => {
row,
null,
);
expect(row.children.length).toBe(2);
expect(row.children).toHaveLength(2);
});
});

describe('addMoreResultsNote', () => {
test('appends note when total exceeds shown', () => {
const container = document.createElement('div');
addMoreResultsNote(container, 100, 60);
expect(container.children.length).toBe(1);
expect(container.children).toHaveLength(1);
expect(container.textContent).toContain('60');
});

test('does nothing when total equals shown', () => {
const container = document.createElement('div');
addMoreResultsNote(container, 60, 60);
expect(container.children.length).toBe(0);
expect(container.children).toHaveLength(0);
});
});

Expand Down Expand Up @@ -294,7 +294,7 @@ describe('item_loader.js', () => {
const para = document.createElement('p');
const footer = document.createElement('div');
addVersionMetadataToFooter({}, para, footer, {}, regionMap, iconMap);
expect(footer.children.length).toBe(0);
expect(footer.children).toHaveLength(0);
});

test('skips metadata key when it has null icon and is not a special key', () => {
Expand All @@ -304,7 +304,7 @@ describe('item_loader.js', () => {
const customIconMap = { media: null, platform_version_release_dates: null, summary: null };
addVersionMetadataToFooter({ media: 'Blu-ray' }, para, footer, {}, regionMap, customIconMap);
// Should not add to footer since icon is null and not a special key
expect(footer.children.length).toBe(0);
expect(footer.children).toHaveLength(0);
});
});

Expand Down
12 changes: 6 additions & 6 deletions tests/platform_detail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,22 @@ describe('platform_detail.js', () => {
test('renders category and generation badges', () => {
renderPlatformBadges({ category: 1, generation: 9 });
const badges = document.getElementById('platform-badges');
expect(badges.children.length).toBe(2);
expect(badges.children).toHaveLength(2);
});

test('renders only category when no generation', () => {
renderPlatformBadges({ category: 2 });
expect(document.getElementById('platform-badges').children.length).toBe(1);
expect(document.getElementById('platform-badges').children).toHaveLength(1);
});

test('renders only generation when no category', () => {
renderPlatformBadges({ generation: 8 });
expect(document.getElementById('platform-badges').children.length).toBe(1);
expect(document.getElementById('platform-badges').children).toHaveLength(1);
});

test('renders nothing when no category or generation', () => {
renderPlatformBadges({});
expect(document.getElementById('platform-badges').children.length).toBe(0);
expect(document.getElementById('platform-badges').children).toHaveLength(0);
});

test('renders fallback text for unknown category number', () => {
Expand Down Expand Up @@ -144,7 +144,7 @@ describe('platform_detail.js', () => {

test('renders nothing when no data', () => {
renderPlatformMetadata({});
expect(document.getElementById('platform-meta').children.length).toBe(0);
expect(document.getElementById('platform-meta').children).toHaveLength(0);
});
});

Expand Down Expand Up @@ -248,7 +248,7 @@ describe('platform_detail.js', () => {
test('renders nothing extra when version is empty', () => {
const body = document.createElement('div');
populateVersionBody(body, {});
expect(body.children.length).toBe(0);
expect(body.children).toHaveLength(0);
});
});

Expand Down