Skip to content

Commit 8fefde6

Browse files
authored
Merge pull request #35 from ashmalzahra/items-counter-test
Items counter test
2 parents 1f26615 + 4d797e7 commit 8fefde6

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/modules/count.test.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
/** @jest-environment jsdom */
2-
// import { countComments } from './comment_handler.js';
2+
import showsCount from './homepage';
3+
34
describe('Homepage items counter Tests', () => {
4-
it('Should test if showsCount is adding all shows to the home page', () => {
5-
let counter = '';
6-
const showInfo = () => ['La Casa de Papel', '1899'];
7-
const showsCount = () => {
8-
const show = showInfo();
9-
counter = `Top binge-worthy shows (${show.length})`;
10-
return counter;
11-
};
5+
document.body.innerHTML = `
6+
<li class="count-shows">Top binge-worthy shows</li>
7+
<main class="container">
8+
<article class="article" id="27436"></article>
9+
<article class="article" id="39749"></article>
10+
</main>
11+
`;
12+
13+
it('Should test if showsCount() is adding all items counter to the home page', () => {
14+
const counter = document.querySelector('.count-shows');
1215
showsCount();
13-
expect(counter).toBe('Top binge-worthy shows (2)');
16+
expect(counter.innerHTML).toBe('Top binge-worthy shows (2)');
1417
});
1518

1619
it('Count comments', () => {

src/modules/homepage.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,5 @@ const displayShows = async () => {
105105
};
106106

107107
displayShows();
108+
109+
export default showsCount;

0 commit comments

Comments
 (0)