Skip to content

Commit

Permalink
test: add tests for TeachingUnitView
Browse files Browse the repository at this point in the history
  • Loading branch information
Flowrey committed Sep 14, 2024
1 parent ec1ef2a commit 453b316
Show file tree
Hide file tree
Showing 4 changed files with 292 additions and 7 deletions.
233 changes: 232 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"devDependencies": {
"@eslint/js": "^9.10.0",
"@playwright/test": "^1.46.1",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/user-event": "^14.5.2",
"@types/jest": "^29.5.12",
"@types/node": "^22.5.2",
"@types/webextension-polyfill": "^0.12.1",
Expand Down
16 changes: 10 additions & 6 deletions tests/teaching_unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import { State, TeachingUnit } from "../src/js/teaching_unit/model";
import { DummyObserver, mockCallback } from "./utils.test";

function newHTMLTeachingUnit(title?: string, code?: string, ects?: number) {
export function newHTMLTeachingUnit(
title?: string,
code?: string,
ects?: number,
) {
let html =
'<div class="ue option clearfix"><div class=" infos-ue"><div class="details clearfix">';
'<div data-testid="teaching-unit" class="ue option clearfix"><div class=" infos-ue"><div class="details clearfix">';

if (ects != null) {
html += `<div class="credits">${ects} ECTS<span class="dico"><span class="icon icon-help_simple"></span></span></div>`;
html += `<div data-testid="ects" class="credits">${ects} ECTS<span class="dico"><span class="icon icon-help_simple"></span></span></div>`;
}
if (title != null) {
html +=
'<h4 class="titre">' +
` <a id="intitule_5df3b7279a53cb218ffb5684789f8939" href="/servlet/uFF?OBJET=ue&amp;CODE=MVA003&amp;LANGUE=0&amp;RF=" target="ue">${title}</a>` +
'<h4 data-testid="title" class="titre">' +
` <a data-testid="title-link" id="intitule_5df3b7279a53cb218ffb5684789f8939" href="/servlet/uFF?OBJET=ue&amp;CODE=MVA003&amp;LANGUE=0&amp;RF=" target="ue">${title}</a>` +
"</h4>";
}
if (code != null) {
html +=
'<div class="code">' +
'<div data-testid="code" class="code">' +
` <a id="code_5df3b7279a53cb218ffb5684789f8939" href="/servlet/uFF?OBJET=ue&amp;CODE=MVA003&amp;LANGUE=0&amp;RF=" target="ue">${code}</a>` +
"</div>";
}
Expand Down
Loading

0 comments on commit 453b316

Please sign in to comment.