Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enables child component stubs #12

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ The `render` function takes up to 3 parameters and returns an object with some h
* props - The component props to be passed to TestComponent
* store - The object definition of a Vuex store, if present `render` will configure a Vuex store and pass to mount.
* routes - A set of routes, if present render will configure VueRouter and pass to mount.
* stubs - [An Array of component names to stub, or an object.](https://vue-test-utils.vuejs.org/api/options.html#stubs)
3. configurationCb - A callback to be called passing the Vue instance when created. This allows 3rd party plugins to be installed prior to mount.

### fireEvent
Expand Down
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const mountedWrappers = new Set()
function render (TestComponent, {
props = null,
store = null,
routes = null
routes = null,
stubs = [],
} = {}, configurationCb) {
const localVue = createLocalVue()
let vuexStore = null
Expand Down Expand Up @@ -43,6 +44,7 @@ function render (TestComponent, {
localVue,
router,
store: vuexStore,
stubs,
propsData: { ...props },
attachToDocument: true,
sync: false
Expand Down
11 changes: 11 additions & 0 deletions tests/__tests__/Integration-with-stub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { render, cleanup, fireEvent } from "../../src"
import Form from "./components/Form"

afterEach(cleanup)

test("Form contians with search button", () => {
const { getByText } = render(Form, {
stubs: ['font-awesome-icon']
})
getByText("Search now")
})
18 changes: 18 additions & 0 deletions tests/__tests__/components/Form.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<form>
<label for="search">
<font-awesome-icon icon="search"/> Search
</label>
<input type="text" id="search" name="search">
<v-button text="Search now"></v-button>
</form>
</template>

<script>
import vButton from './Button';

export default {
name: 'searchForm',
components: { vButton },
}
</script>