Browse Source

[test] add test for i18n currentLocale

pull/595/head
LouisLam 3 years ago
parent
commit
11abc1f1e0
  1. 15
      jest.config.js
  2. 10
      package.json
  3. 6
      src/main.js
  4. 2
      src/util.js
  5. 2
      src/util.ts
  6. 9
      test/test.spec.js
  7. 3
      test/test_install_script/ubuntu.dockerfile

15
jest.config.js

@ -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"
}
};

10
package.json

@ -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
}
}

6
src/main.js

@ -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;
}

2
src/util.js

@ -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");
}
}

2
src/util.ts

@ -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")
}
}

9
test/test.spec.js

@ -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);

3
test/test_install_script/ubuntu.dockerfile

@ -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

Loading…
Cancel
Save