improve tests (#2923)

use es6 syntax in all tests, split weather tests, remove callbacks
This commit is contained in:
Karsten Hassel
2022-10-04 10:15:24 +02:00
committed by GitHub
parent 7694d6fa86
commit f04d578704
41 changed files with 751 additions and 840 deletions

View File

@@ -1,31 +1,31 @@
const path = require("path");
const { JSDOM } = require("jsdom");
describe("Test function cmpVersions in js/module.js", function () {
describe("Test function cmpVersions in js/module.js", () => {
let cmp;
beforeAll(function (done) {
beforeAll((done) => {
const dom = new JSDOM(
`<script>var Class = {extend: function() { return {}; }};</script>\
`<script>var Class = {extend: () => { return {}; }};</script>\
<script src="file://${path.join(__dirname, "..", "..", "..", "js", "module.js")}">`,
{ runScripts: "dangerously", resources: "usable" }
);
dom.window.onload = function () {
dom.window.onload = () => {
const { cmpVersions } = dom.window;
cmp = cmpVersions;
done();
};
});
it("should return -1 when comparing 2.1 to 2.2", function () {
it("should return -1 when comparing 2.1 to 2.2", () => {
expect(cmp("2.1", "2.2")).toBe(-1);
});
it("should be return 0 when comparing 2.2 to 2.2", function () {
it("should be return 0 when comparing 2.2 to 2.2", () => {
expect(cmp("2.2", "2.2")).toBe(0);
});
it("should be return 1 when comparing 1.1 to 1.0", function () {
it("should be return 1 when comparing 1.1 to 1.0", () => {
expect(cmp("1.1", "1.0")).toBe(1);
});
});