mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-22 13:09:26 +00:00
Enhance compliments remote file with refresh support (#3630)
add support to refresh the compliments remotefile add testcases for both without refresh (testcase missing) and with refresh doc to be updated
This commit is contained in:
17
tests/configs/modules/compliments/compliments_file.js
Normal file
17
tests/configs/modules/compliments/compliments_file.js
Normal file
@@ -0,0 +1,17 @@
|
||||
let config = {
|
||||
address: "0.0.0.0",
|
||||
ipWhitelist: [],
|
||||
modules: [
|
||||
{
|
||||
module: "compliments",
|
||||
position: "bottom_bar",
|
||||
config: {
|
||||
updateInterval: 3000,
|
||||
remoteFile: "http://localhost:8080/tests/mocks/compliments_test.json"
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||
if (typeof module !== "undefined") { module.exports = config; }
|
19
tests/configs/modules/compliments/compliments_file_change.js
Normal file
19
tests/configs/modules/compliments/compliments_file_change.js
Normal file
@@ -0,0 +1,19 @@
|
||||
let config = {
|
||||
address: "0.0.0.0",
|
||||
ipWhitelist: [],
|
||||
modules: [
|
||||
{
|
||||
module: "compliments",
|
||||
position: "bottom_bar",
|
||||
config: {
|
||||
updateInterval: 3000,
|
||||
remoteFileRefreshInterval: 1500,
|
||||
remoteFile: "http://localhost:8080/tests/mocks/compliments_test.json",
|
||||
remoteFile2: "http://localhost:8080/tests/mocks/compliments_file.json"
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||
if (typeof module !== "undefined") { module.exports = config; }
|
@@ -78,6 +78,22 @@ describe("Compliments module", () => {
|
||||
await expect(doTest(["just a test"])).resolves.toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Feature remote compliments file", () => {
|
||||
describe("get list from remote file", () => {
|
||||
it("shows 'Remote compliment file works!' as only anytime list set", async () => {
|
||||
await helpers.startApplication("tests/configs/modules/compliments/compliments_file.js", "01 Jan 2022 10:00:00 GMT");
|
||||
await expect(doTest(["Remote compliment file works!"])).resolves.toBe(true);
|
||||
});
|
||||
});
|
||||
describe("get updated list from remote file", () => {
|
||||
it("shows 'test in morning' as test time set to 10am", async () => {
|
||||
await helpers.startApplication("tests/configs/modules/compliments/compliments_file_change.js", "01 Jan 2022 10:00:00 GMT");
|
||||
await expect(doTest(["Remote compliment file works!"])).resolves.toBe(true);
|
||||
await new Promise((r) => setTimeout(r, 10000));
|
||||
await expect(doTest(["test in morning"])).resolves.toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
5
tests/mocks/compliments_file.json
Normal file
5
tests/mocks/compliments_file.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"morning": ["test in morning"],
|
||||
"afternoon": ["test in afternoon"],
|
||||
"evening": ["test in evening"]
|
||||
}
|
Reference in New Issue
Block a user