Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
QUnit.test("myPlugin initializes correctly", function(assert) { const $el = $("<div>").appendTo("#qunit-fixture"); $el.myPlugin({ color: "red" }); assert.ok($el.data("myPlugin"), "Instance stored in data"); assert.equal($el.css("color"), "rgb(255, 0, 0)", "Color applied"); }); QUnit.test("myPlugin destroy cleans up", function(assert) { const $el = $("<div>").myPlugin(); $el.myPlugin("destroy"); assert.notOk($el.data("myPlugin"), "Instance removed"); });
Result
Open