mirror of
https://github.com/MichMich/MagicMirror.git
synced 2026-04-24 06:47:07 +00:00
Enable the `require-await` ESLint rule. Async functions without `await` are just regular functions with extra overhead — marking them `async` adds implicit Promise wrapping, can hide missing `return` statements, and misleads readers into expecting asynchronous behavior where there is none. While fixing the violations, I removed unnecessary `async` keywords from source files and from various test callbacks that never used `await`.
55 lines
955 B
JavaScript
55 lines
955 B
JavaScript
global.moment = require("moment-timezone");
|
|
const defaults = require("../../../../js/defaults");
|
|
|
|
const { formatTime } = require(`../../../../${defaults.defaultModulesDir}/utils`);
|
|
|
|
describe("Default modules utils tests", () => {
|
|
describe("formatTime", () => {
|
|
const time = new Date();
|
|
|
|
beforeEach(() => {
|
|
time.setHours(13, 13);
|
|
});
|
|
|
|
it("should convert correctly according to the config", () => {
|
|
expect(
|
|
formatTime(
|
|
{
|
|
timeFormat: 24
|
|
},
|
|
time
|
|
)
|
|
).toBe("13:13");
|
|
expect(
|
|
formatTime(
|
|
{
|
|
showPeriod: true,
|
|
showPeriodUpper: true,
|
|
timeFormat: 12
|
|
},
|
|
time
|
|
)
|
|
).toBe("1:13 PM");
|
|
expect(
|
|
formatTime(
|
|
{
|
|
showPeriod: true,
|
|
showPeriodUpper: false,
|
|
timeFormat: 12
|
|
},
|
|
time
|
|
)
|
|
).toBe("1:13 pm");
|
|
expect(
|
|
formatTime(
|
|
{
|
|
showPeriod: false,
|
|
timeFormat: 12
|
|
},
|
|
time
|
|
)
|
|
).toBe("1:13");
|
|
});
|
|
});
|
|
});
|