From 55cde2948fa96bcccc44db65dd34bc6a7217a6a3 Mon Sep 17 00:00:00 2001 From: Emanuele Date: Sat, 18 May 2019 18:21:27 +0100 Subject: [PATCH] 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 * Update README.md Co-Authored-By: Ben Monro --- package-lock.json | 2 +- package.json | 2 +- src/index.js | 1 + tests/render.spec.js | 8 ++++++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 27d70ef..044b446 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "svlt-testing-library", + "name": "svelte-testing-library", "version": "0.0.0-semantically-released", "lockfileVersion": 1, "requires": true, diff --git a/package.json b/package.json index 5cb2207..0b0e932 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "jest": "^24.7.1", "jest-dom": "^3.1.2", "jest-transform-svelte": "^1.0.0", - "kcd-scripts": "^1.2.1", + "kcd-scripts": "^1.4.0", "npm-run-all": "^4.1.5", "rollup": "^1.10.1", "rollup-plugin-commonjs": "^9.3.4", diff --git a/src/index.js b/src/index.js index eff31a0..91c8286 100644 --- a/src/index.js +++ b/src/index.js @@ -17,6 +17,7 @@ export const render = (Component, {target, ...options} = {}) => { component, // eslint-disable-next-line no-console debug: (el = document.body) => console.log(prettyDOM(el)), + container: document.body, ...getQueriesForElement(document.body), } } diff --git a/tests/render.spec.js b/tests/render.spec.js index 4a65481..8b9ea36 100644 --- a/tests/render.spec.js +++ b/tests/render.spec.js @@ -74,4 +74,12 @@ describe('render', () => { expect(document.body.innerHTML).toBe('') }) + + test('should return a container object, which contains the DOM of the rendered component', () => { + const {container} = render(App, {props: {name: 'world'}}) + + expect(container.innerHTML).toBe(document.body.innerHTML) + + cleanup() + }) })