Skip to content

Commit 235feae

Browse files
committed
add de tests
1 parent 74bf35f commit 235feae

File tree

5 files changed

+91
-4
lines changed

5 files changed

+91
-4
lines changed

.husky/pre-commit

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22

3-
if command -v npx &> /dev/null; then
4-
npx lint-staged
3+
# Get the path to the project root
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
5+
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
6+
7+
# Add node_modules/.bin to PATH
8+
PATH="$PROJECT_ROOT/node_modules/.bin:$PATH"
9+
10+
# Source NVM if available
11+
export NVM_DIR="$HOME/.nvm"
12+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
13+
14+
# Run lint-staged
15+
if [ -f "$PROJECT_ROOT/node_modules/.bin/lint-staged" ]; then
16+
"$PROJECT_ROOT/node_modules/.bin/lint-staged"
17+
else
18+
npx lint-staged
519
fi

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"lint:markdown": "markdownlint-cli2 . --fix",
3535
"lint:prettier": "prettier . --write",
3636
"postinstall": "node --run install-vendor && node --run install-fonts && echo \"MagicMirror² installation finished successfully! \n\"",
37-
"prepare": "[ -f node_modules/.bin/husky ] && husky || echo no husky installed.",
37+
"prepare": "husky install",
3838
"server": "node ./serveronly",
3939
"start": "node --run start:x11",
4040
"start:dev": "node --run start:x11 -- dev",
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
let config = {
2+
address: "0.0.0.0",
3+
ipWhitelist: [],
4+
language: "de",
5+
timeFormat: 12,
6+
7+
modules: [
8+
{
9+
module: "clock",
10+
position: "middle_center",
11+
config: {
12+
showWeek: true
13+
}
14+
}
15+
]
16+
};
17+
18+
/*************** DO NOT EDIT THE LINE BELOW ***************/
19+
if (typeof module !== "undefined") {
20+
module.exports = config;
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
let config = {
2+
address: "0.0.0.0",
3+
ipWhitelist: [],
4+
language: "de",
5+
timeFormat: 12,
6+
7+
modules: [
8+
{
9+
module: "clock",
10+
position: "middle_center",
11+
config: {
12+
showWeek: "short"
13+
}
14+
}
15+
]
16+
};
17+
18+
/*************** DO NOT EDIT THE LINE BELOW ***************/
19+
if (typeof module !== "undefined") {
20+
module.exports = config;
21+
}

tests/e2e/modules/clock_de_spec.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const helpers = require("../helpers/global-setup");
2+
3+
describe("Clock set to german language module", () => {
4+
afterAll(async () => {
5+
await helpers.stopApplication();
6+
});
7+
8+
describe("with showWeek config enabled", () => {
9+
beforeAll(async () => {
10+
await helpers.startApplication("tests/configs/modules/clock/de/clock_showWeek.js");
11+
await helpers.getDocument();
12+
});
13+
14+
it("shows week with correct format", async () => {
15+
const weekRegex = /^[0-9]{1,2}. Kalenderwoche$/;
16+
await expect(helpers.testMatch(".clock .week", weekRegex)).resolves.toBe(true);
17+
});
18+
});
19+
20+
describe("with showWeek short config enabled", () => {
21+
beforeAll(async () => {
22+
await helpers.startApplication("tests/configs/modules/clock/de/clock_showWeek_short.js");
23+
await helpers.getDocument();
24+
});
25+
26+
it("shows week with correct format", async () => {
27+
const weekRegex = /^[0-9]{1,2}KW$/;
28+
await expect(helpers.testMatch(".clock .week", weekRegex)).resolves.toBe(true);
29+
});
30+
});
31+
});

0 commit comments

Comments
 (0)