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
23 changes: 13 additions & 10 deletions src/modules/count.test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
/** @jest-environment jsdom */
// import { countComments } from './comment_handler.js';
import showsCount from './homepage';

describe('Homepage items counter Tests', () => {
it('Should test if showsCount is adding all shows to the home page', () => {
let counter = '';
const showInfo = () => ['La Casa de Papel', '1899'];
const showsCount = () => {
const show = showInfo();
counter = `Top binge-worthy shows (${show.length})`;
return counter;
};
document.body.innerHTML = `
<li class="count-shows">Top binge-worthy shows</li>
<main class="container">
<article class="article" id="27436"></article>
<article class="article" id="39749"></article>
</main>
`;

it('Should test if showsCount() is adding all items counter to the home page', () => {
const counter = document.querySelector('.count-shows');
showsCount();
expect(counter).toBe('Top binge-worthy shows (2)');
expect(counter.innerHTML).toBe('Top binge-worthy shows (2)');
});

it('Count comments', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/modules/homepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,5 @@ const displayShows = async () => {
};

displayShows();

export default showsCount;