1
0
mirror of https://github.com/louislam/uptime-kuma.git synced 2024-11-28 08:48:45 +02:00

[test] add test for i18n currentLocale

This commit is contained in:
LouisLam 2021-10-08 13:35:04 +08:00
parent 288e87bb3d
commit 11abc1f1e0
7 changed files with 33 additions and 14 deletions

15
jest.config.js Normal file
View File

@ -0,0 +1,15 @@
module.exports = {
"verbose": true,
"preset": "jest-puppeteer",
"globals": {
"__DEV__": true
},
"testRegex": "./test/*.spec.js",
"rootDir": ".",
"testTimeout": 30000,
"transform": {
"^.+\\.js$": "babel-jest",
".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub"
}
};

View File

@ -115,15 +115,5 @@
"stylelint-config-standard": "~22.0.0",
"typescript": "~4.4.3",
"vite": "~2.6.4"
},
"jest": {
"verbose": true,
"preset": "jest-puppeteer",
"globals": {
"__DEV__": true
},
"testRegex": "./test/*.spec.js",
"rootDir": ".",
"testTimeout": 30000
}
}

View File

@ -43,3 +43,9 @@ app.component("Editable", contenteditable);
app.component("FontAwesomeIcon", FontAwesomeIcon);
app.mount("#app");
// Expose the vue instance for development
if (process.env.NODE_ENV === "development") {
console.log("Dev Only: window.app is the vue instance");
window.app = app._instance;
}

View File

@ -74,7 +74,7 @@ class TimeLogger {
this.startTime = dayjs().valueOf();
}
print(name) {
if (exports.isDev && process && process.env.TIMELOGGER === "1") {
if (exports.isDev && process.env.TIMELOGGER === "1") {
console.log(name + ": " + (dayjs().valueOf() - this.startTime) + "ms");
}
}

View File

@ -86,7 +86,7 @@ export class TimeLogger {
}
print(name: string) {
if (isDev && process && process.env.TIMELOGGER === "1") {
if (isDev && process.env.TIMELOGGER === "1") {
console.log(name + ": " + (dayjs().valueOf() - this.startTime) + "ms")
}
}

View File

@ -2,6 +2,7 @@
const { Page, Browser } = require("puppeteer");
const { sleep } = require("../src/util");
const axios = require("axios");
const { currentLocale } = require("../src/i18n");
/**
* Set back the correct data type for page object
@ -223,6 +224,14 @@ describe("Init", () => {
});
});
describe("Test i18n.js", () => {
it("currentLocale()", () => {
expect(currentLocale()).toMatch("");
});
});
async function login(username, password) {
await input(page, "#floatingInput", username);
await input(page, "#floatingPassword", password);

View File

@ -6,5 +6,4 @@ FROM ubuntu
# RUN ln -s /usr/bin/nodejs /usr/bin/node
# RUN node -v
COPY ./install.sh .
RUN bash install.sh local /opt/uptime-kuma 3000 0.0.0.0
RUN curl -o kuma_install.sh http://git.kuma.pet/install.sh && bash kuma_install.sh local /opt/uptime-kuma 3000 0.0.0.0