[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", "stylelint-config-standard": "~22.0.0",
"typescript": "~4.4.3", "typescript": "~4.4.3",
"vite": "~2.6.4" "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.component("FontAwesomeIcon", FontAwesomeIcon);
app.mount("#app"); 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(); this.startTime = dayjs().valueOf();
} }
print(name) { 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"); console.log(name + ": " + (dayjs().valueOf() - this.startTime) + "ms");
} }
} }

View file

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

View file

@ -2,6 +2,7 @@
const { Page, Browser } = require("puppeteer"); const { Page, Browser } = require("puppeteer");
const { sleep } = require("../src/util"); const { sleep } = require("../src/util");
const axios = require("axios"); const axios = require("axios");
const { currentLocale } = require("../src/i18n");
/** /**
* Set back the correct data type for page object * 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) { async function login(username, password) {
await input(page, "#floatingInput", username); await input(page, "#floatingInput", username);
await input(page, "#floatingPassword", password); await input(page, "#floatingPassword", password);

View file

@ -6,5 +6,4 @@ FROM ubuntu
# RUN ln -s /usr/bin/nodejs /usr/bin/node # RUN ln -s /usr/bin/nodejs /usr/bin/node
# RUN node -v # RUN node -v
COPY ./install.sh . 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
RUN bash install.sh local /opt/uptime-kuma 3000 0.0.0.0