Skip to content

Commit 55cde29

Browse files
ematipicobenmonro
andcommitted
feat: added container to the API (#24)
* feat: added container to the API - added example - added test - bumped library to fix low vulnerability * Update README.md Co-Authored-By: Ben Monro <[email protected]> * Update README.md Co-Authored-By: Ben Monro <[email protected]>
1 parent 5704d92 commit 55cde29

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"jest": "^24.7.1",
1515
"jest-dom": "^3.1.2",
1616
"jest-transform-svelte": "^1.0.0",
17-
"kcd-scripts": "^1.2.1",
17+
"kcd-scripts": "^1.4.0",
1818
"npm-run-all": "^4.1.5",
1919
"rollup": "^1.10.1",
2020
"rollup-plugin-commonjs": "^9.3.4",

src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const render = (Component, {target, ...options} = {}) => {
1717
component,
1818
// eslint-disable-next-line no-console
1919
debug: (el = document.body) => console.log(prettyDOM(el)),
20+
container: document.body,
2021
...getQueriesForElement(document.body),
2122
}
2223
}

tests/render.spec.js

+8
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,12 @@ describe('render', () => {
7474

7575
expect(document.body.innerHTML).toBe('')
7676
})
77+
78+
test('should return a container object, which contains the DOM of the rendered component', () => {
79+
const {container} = render(App, {props: {name: 'world'}})
80+
81+
expect(container.innerHTML).toBe(document.body.innerHTML)
82+
83+
cleanup()
84+
})
7785
})

0 commit comments

Comments
 (0)