mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-09 23:24:07 -08:00
Remove babel-plugin-rewire (#3522)
This commit is contained in:
parent
f4967615c0
commit
d231a05526
|
@ -4,8 +4,4 @@ if (process.env.TEST_FRONTEND) {
|
|||
config.presets = [ "@babel/preset-env" ];
|
||||
}
|
||||
|
||||
if (process.env.TEST_BACKEND) {
|
||||
config.plugins = [ "babel-plugin-rewire" ];
|
||||
}
|
||||
|
||||
module.exports = config;
|
||||
|
|
7
package-lock.json
generated
7
package-lock.json
generated
|
@ -90,7 +90,6 @@
|
|||
"@vue/compiler-sfc": "~3.3.4",
|
||||
"@vuepic/vue-datepicker": "~3.4.8",
|
||||
"aedes": "^0.46.3",
|
||||
"babel-plugin-rewire": "~1.2.0",
|
||||
"bootstrap": "5.1.3",
|
||||
"chart.js": "~4.2.1",
|
||||
"chartjs-adapter-dayjs-4": "~1.0.4",
|
||||
|
@ -6623,12 +6622,6 @@
|
|||
"@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/babel-plugin-rewire": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-plugin-rewire/-/babel-plugin-rewire-1.2.0.tgz",
|
||||
"integrity": "sha512-JBZxczHw3tScS+djy6JPLMjblchGhLI89ep15H3SyjujIzlxo5nr6Yjo7AXotdeVczeBmWs0tF8PgJWDdgzAkQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/babel-preset-current-node-syntax": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz",
|
||||
|
|
|
@ -153,7 +153,6 @@
|
|||
"@vue/compiler-sfc": "~3.3.4",
|
||||
"@vuepic/vue-datepicker": "~3.4.8",
|
||||
"aedes": "^0.46.3",
|
||||
"babel-plugin-rewire": "~1.2.0",
|
||||
"bootstrap": "5.1.3",
|
||||
"chart.js": "~4.2.1",
|
||||
"chartjs-adapter-dayjs-4": "~1.0.4",
|
||||
|
|
|
@ -1047,3 +1047,13 @@ module.exports.grpcQuery = async (options) => {
|
|||
|
||||
});
|
||||
};
|
||||
|
||||
// For unit test, export functions
|
||||
if (process.env.TEST_BACKEND) {
|
||||
module.exports.__test = {
|
||||
parseCertificateInfo,
|
||||
};
|
||||
module.exports.__getPrivateFunction = (functionName) => {
|
||||
return module.exports.__test[functionName];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const { genSecret, DOWN, log} = require("../src/util");
|
||||
const utilServerRewire = require("../server/util-server");
|
||||
const utilServer = require("../server/util-server");
|
||||
const Discord = require("../server/notification-providers/discord");
|
||||
const axios = require("axios");
|
||||
const { UptimeKumaServer } = require("../server/uptime-kuma-server");
|
||||
|
@ -14,13 +14,13 @@ jest.mock("axios");
|
|||
|
||||
describe("Test parseCertificateInfo", () => {
|
||||
it("should handle undefined", async () => {
|
||||
const parseCertificateInfo = utilServerRewire.__get__("parseCertificateInfo");
|
||||
const parseCertificateInfo = utilServer.__getPrivateFunction("parseCertificateInfo");
|
||||
const info = parseCertificateInfo(undefined);
|
||||
expect(info).toEqual(undefined);
|
||||
}, 5000);
|
||||
|
||||
it("should handle normal cert chain", async () => {
|
||||
const parseCertificateInfo = utilServerRewire.__get__("parseCertificateInfo");
|
||||
const parseCertificateInfo = utilServer.__getPrivateFunction("parseCertificateInfo");
|
||||
|
||||
const chain1 = {
|
||||
fingerprint: "CF:2C:F3:6A:FE:6B:10:EC:44:77:C8:95:BB:96:2E:06:1F:0E:15:DA",
|
||||
|
@ -52,7 +52,7 @@ describe("Test parseCertificateInfo", () => {
|
|||
}, 5000);
|
||||
|
||||
it("should handle cert chain with strange circle", async () => {
|
||||
const parseCertificateInfo = utilServerRewire.__get__("parseCertificateInfo");
|
||||
const parseCertificateInfo = utilServer.__getPrivateFunction("parseCertificateInfo");
|
||||
|
||||
const chain1 = {
|
||||
fingerprint: "CF:2C:F3:6A:FE:6B:10:EC:44:77:C8:95:BB:96:2E:06:1F:0E:15:DA",
|
||||
|
@ -92,7 +92,7 @@ describe("Test parseCertificateInfo", () => {
|
|||
}, 5000);
|
||||
|
||||
it("should handle cert chain with last undefined (should be happen in real, but just in case)", async () => {
|
||||
const parseCertificateInfo = utilServerRewire.__get__("parseCertificateInfo");
|
||||
const parseCertificateInfo = utilServer.__getPrivateFunction("parseCertificateInfo");
|
||||
|
||||
const chain1 = {
|
||||
fingerprint: "CF:2C:F3:6A:FE:6B:10:EC:44:77:C8:95:BB:96:2E:06:1F:0E:15:DA",
|
||||
|
@ -213,22 +213,22 @@ describe("Test Discord Notification Provider", () => {
|
|||
|
||||
describe("The function filterAndJoin", () => {
|
||||
it("should join and array of strings to one string", () => {
|
||||
const result = utilServerRewire.filterAndJoin([ "one", "two", "three" ]);
|
||||
const result = utilServer.filterAndJoin([ "one", "two", "three" ]);
|
||||
expect(result).toBe("onetwothree");
|
||||
});
|
||||
|
||||
it("should join strings using a given connector", () => {
|
||||
const result = utilServerRewire.filterAndJoin([ "one", "two", "three" ], "-");
|
||||
const result = utilServer.filterAndJoin([ "one", "two", "three" ], "-");
|
||||
expect(result).toBe("one-two-three");
|
||||
});
|
||||
|
||||
it("should filter null, undefined and empty strings before joining", () => {
|
||||
const result = utilServerRewire.filterAndJoin([ undefined, "", "three" ], "--");
|
||||
const result = utilServer.filterAndJoin([ undefined, "", "three" ], "--");
|
||||
expect(result).toBe("three");
|
||||
});
|
||||
|
||||
it("should return an empty string if all parts are filtered out", () => {
|
||||
const result = utilServerRewire.filterAndJoin([ undefined, "", "" ], "--");
|
||||
const result = utilServer.filterAndJoin([ undefined, "", "" ], "--");
|
||||
expect(result).toBe("");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue