Skip to content

Update deps #79

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

Merged
merged 4 commits into from
Aug 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"author": "Daniel Cook",
"license": "MIT",
"dependencies": {
"@testing-library/dom": "^5.6.0",
"@testing-library/dom": "^6.0.0",
"@vue/test-utils": "^1.0.0-beta.29"
},
"devDependencies": {
Expand All @@ -55,17 +55,17 @@
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^5.2.3",
"husky": "^3.0.2",
"husky": "^3.0.3",
"jest": "^24.8.0",
"jest-in-case": "^1.0.2",
"jest-serializer-vue": "^2.0.2",
"lint-staged": "^9.2.1",
"prettier": "^1.18.2",
"vee-validate": "^2.2.13",
"vue": "^2.6.10",
"vue-i18n": "^8.12.0",
"vue-i18n": "^8.13.0",
"vue-jest": "^3.0.4",
"vue-router": "^3.0.7",
"vue-router": "^3.1.2",
"vue-template-compiler": "^2.6.10",
"vuex": "^3.1.1"
},
Expand Down
4 changes: 2 additions & 2 deletions src/vue-testing-library.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createLocalVue, mount } from '@vue/test-utils'

import {
getQueriesForElement,
prettyDOM,
logDOM,
wait,
fireEvent
} from '@testing-library/dom'
Expand Down Expand Up @@ -63,7 +63,7 @@ function render(
return {
container: wrapper.element.parentNode,
baseElement: document.body,
debug: (el = wrapper.element) => console.log(prettyDOM(el)),
debug: (el = wrapper.element) => logDOM(el),
unmount: () => wrapper.destroy(),
isUnmounted: () => wrapper.vm._isDestroyed,
html: () => wrapper.html(),
Expand Down
13 changes: 6 additions & 7 deletions tests/__tests__/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ test('Review form submits', async () => {
const fakeReview = {
title: 'An Awesome Movie',
review: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
rating: '3',
recommend: true
rating: '3'
}

const {
Expand Down Expand Up @@ -46,7 +45,7 @@ test('Review form submits', async () => {
expect(ratingSelect.checked).toBe(true)
expect(initiallySelectedInput.checked).toBe(false)

// Get the Input element by its implicit ARIA role.
// Get the Input element by its implicit ARIA role
const recommendInput = getByRole('checkbox')

expect(recommendInput.checked).toBe(false)
Expand All @@ -56,13 +55,13 @@ test('Review form submits', async () => {
// NOTE: in jsdom, it's not possible to trigger a form submission
// by clicking on the submit button. This is really unfortunate.
// So the next best thing is to fireEvent a submit on the form itself
// then ensure that there's a submit button.
// then ensure that there's a submit button
expect(submitButton).toBeEnabled()
expect(submitButton).toHaveAttribute('type', 'submit')

await fireEvent.click(submitButton)

// Assert event has been emitted.
expect(emitted().submit).toHaveLength(1)
expect(emitted().submit[0]).toEqual([fakeReview])
// Assert event has been emitted
expect(emitted()).toHaveProperty('submit')
expect(emitted().submit[0][0]).toMatchObject(fakeReview)
})
11 changes: 8 additions & 3 deletions tests/__tests__/simple-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ test('renders button with text', () => {
props: { text }
})

expect(getByRole('button')).toHaveTextContent(text)
// Get the only element with a 'button' role
const button = getByRole('button')

expect(button).toHaveTextContent(text)
})

test('click event is emitted when button is clicked', async () => {
Expand All @@ -22,8 +25,10 @@ test('click event is emitted when button is clicked', async () => {
props: { text }
})

// Send a click event to the element with a 'button' role
// Send a click event
await fireEvent.click(getByRole('button'))

expect(emitted().click).toHaveLength(1)
// Expect that the event emitted a "click" event. We should test for emitted
// events has they are part of the public API of the component
expect(emitted()).toHaveProperty('click')
})