Last active
January 27, 2019 10:37
-
-
Save unlocomqx/2e2c9a682633f10408ea815c9c4295a0 to your computer and use it in GitHub Desktop.
Testing jQuery with Mocha (TypeScript)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// based on https://gist.github.com/robballou/9ee108758dc5e0e2d028 | |
// install dependencies if needed: npm i -S jquery @types/jquery jsdom @types/jsdom | |
import { expect } from "chai"; | |
import { JSDOM } from "jsdom"; | |
import "mocha"; | |
import { Utils } from "ts/libs/utils/Utils"; | |
const { window } = new JSDOM(); | |
const $ = (global as any).jQuery = require("jquery")(window); | |
describe("Utils Class", () => { | |
const utils = new Utils(); | |
it("should check that element has all classes", () => { | |
const element = $(`<div class="cls1 cls2 cls3"></div>`); | |
expect(utils.hasAllClasses(element, ["cls1", "cls2", "cls3"])).to.be.true; | |
expect(utils.hasAllClasses(element, ["cls1", "cls4"])).to.be.false; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment