2019-06-04 10:43:06 +02:00
|
|
|
const expect = require("chai").expect;
|
2018-02-15 23:53:57 +01:00
|
|
|
const path = require("path");
|
|
|
|
const {JSDOM} = require("jsdom");
|
2017-01-15 15:40:23 -03:00
|
|
|
|
2017-01-23 09:46:50 -08:00
|
|
|
describe("Test function cmpVersions in js/module.js", function() {
|
2018-02-15 23:53:57 +01:00
|
|
|
let cmp;
|
|
|
|
|
|
|
|
before(function(done) {
|
|
|
|
const dom = new JSDOM(`<script>var Class = {extend: function() { return {}; }};</script>\
|
|
|
|
<script src="${path.join(__dirname, "..", "..", "..", "js", "module.js")}">`, { runScripts: "dangerously",
|
|
|
|
resources: "usable" });
|
|
|
|
dom.window.onload = function() {
|
|
|
|
const {cmpVersions} = dom.window;
|
|
|
|
cmp = cmpVersions;
|
|
|
|
done();
|
|
|
|
};
|
|
|
|
});
|
2017-01-15 15:40:23 -03:00
|
|
|
|
2017-01-23 09:46:50 -08:00
|
|
|
it("should return -1 when comparing 2.1 to 2.2", function() {
|
2018-02-15 23:53:57 +01:00
|
|
|
expect(cmp("2.1", "2.2")).to.equal(-1);
|
2017-01-15 15:40:23 -03:00
|
|
|
});
|
|
|
|
|
2017-01-23 09:46:50 -08:00
|
|
|
it("should be return 0 when comparing 2.2 to 2.2", function() {
|
2018-02-15 23:53:57 +01:00
|
|
|
expect(cmp("2.2", "2.2")).to.equal(0);
|
2017-01-15 15:40:23 -03:00
|
|
|
});
|
|
|
|
|
2017-01-23 09:46:50 -08:00
|
|
|
it("should be return 1 when comparing 1.1 to 1.0", function() {
|
2018-02-15 23:53:57 +01:00
|
|
|
expect(cmp("1.1", "1.0")).to.equal(1);
|
2017-01-15 15:40:23 -03:00
|
|
|
});
|
|
|
|
});
|