Skip to content

Commit

Permalink
added tests for destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
BowlingX committed Sep 28, 2015
1 parent 66885b1 commit cefcee7
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/test/Marklib.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,30 @@ describe('Constructor Arguments', () => {
.toEqual('highlight comment');
});
});

describe("Cleanup", () => {
beforeEach(() => {
loadFixtures('simple-text.html');
});

it("Must cleanup bindings to nodes after destroying", () => {
const renderer = new Rendering(document, 'highlight comment');
expect(renderer.cssClass instanceof Array).toEqual(true);
const range = document.createRange();

range.setStart(document.getElementById("p").childNodes[0], 0);
range.setEnd(document.getElementById("p").childNodes[0], 10);

renderer.renderWithRange(range);
const nodes = document.getElementById("p").childNodes[0];
expect(nodes.className)
.toEqual('highlight comment');
expect(nodes.marklibInstance instanceof Rendering).toEqual(true);
renderer.destroy();

expect(document.getElementById("p").childNodes[0].className)
.toBe('');

expect(nodes.marklibInstance).toBeUndefined();
});
});

0 comments on commit cefcee7

Please sign in to comment.