Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #506 from Mas0nShi/451-fixes-missing-innerHTML-in-…
…html-template #451 fixes missing inner html in html template
- Loading branch information
Showing
2 changed files
with
87 additions
and
42 deletions.
There are no files selected for viewing
This file contains 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
29 changes: 29 additions & 0 deletions
29
packages/happy-dom/test/nodes/html-template-element/HTMLTemplateElement.test.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Window from '../../../src/window/Window'; | ||
import Document from '../../../src/nodes/document/Document'; | ||
import HTMLTemplateElement from '../../../src/nodes/html-template-element/HTMLTemplateElement'; | ||
|
||
describe('HTMLTemplateElement', () => { | ||
let window: Window; | ||
let document: Document; | ||
let element: HTMLTemplateElement; | ||
|
||
beforeEach(() => { | ||
window = new Window(); | ||
document = window.document; | ||
element = <HTMLTemplateElement>document.createElement('template'); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
it('InnerHTML', () => { | ||
const div = '<div>happy-dom is cool!</div>'; | ||
expect(element.content.childNodes.length).toBe(0); | ||
element.innerHTML = div; | ||
expect(element.innerHTML).toBe(div); | ||
expect(element.content.childNodes.length).toBe(1); | ||
element.innerHTML = ''; | ||
expect(element.content.childNodes.length).toBe(0); | ||
}); | ||
}); |