Skip to content

Commit ddbf449

Browse files
committed
Fix linting issues
1 parent f32975a commit ddbf449

14 files changed

+29
-20
lines changed

.eslintrc.js

+4
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,9 @@ module.exports = {
88
rules: {
99
'no-console': 'off',
1010
'import/no-unresolved': 'off',
11+
12+
'testing-library/no-dom-import': 'off',
13+
'testing-library/prefer-screen-queries': 'off',
14+
'testing-library/no-manual-cleanup': 'off',
1115
},
1216
}

src/__tests__/axios-mock.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test('mocks an API call when load-greeting is clicked', async () => {
1616

1717
expect(axiosMock.get).toHaveBeenCalledTimes(1)
1818
expect(axiosMock.get).toHaveBeenCalledWith('/greeting')
19-
getByText('hello there')
19+
expect(getByText('hello there')).toBeInTheDocument()
2020

2121
// You can render component snapshots by using html(). However, bear in mind
2222
// that Snapshot Testing should not be treated as a replacement for regular

src/__tests__/debug.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable testing-library/no-debug */
12
import {render} from '@testing-library/vue'
23
import HelloWorld from './components/HelloWorld'
34

src/__tests__/directive.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import Directive from './components/Directive'
88
test('Component with a custom directive', () => {
99
// Do not forget to add the new custom directive to the render function as
1010
// the third parameter.
11-
const {queryByText} = render(Directive, {}, vue =>
11+
const {queryByText, getByText} = render(Directive, {}, vue =>
1212
vue.directive('uppercase', uppercaseDirective),
1313
)
1414

1515
// Test that the text in lower case does not appear in the DOM
1616
expect(queryByText('example text')).not.toBeInTheDocument()
1717

1818
// Test that the text in upper case does appear in the DOM thanks to the directive
19-
expect(queryByText('EXAMPLE TEXT')).toBeInTheDocument()
19+
expect(getByText('EXAMPLE TEXT')).toBeInTheDocument()
2020
})

src/__tests__/disappearance.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test('waits for the data to be loaded', async () => {
66
const {getByText, queryByText, queryByTestId} = render(Disappearance)
77

88
// Assert initial state
9-
getByText('Loading...')
9+
expect(getByText('Loading...')).toBeInTheDocument()
1010
expect(queryByText(/Loaded this message/)).not.toBeInTheDocument()
1111

1212
// Following line reads as follows:

src/__tests__/form.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,20 @@ test('Review form submits', async () => {
3737
const initiallySelectedInput = getByLabelText('Awful')
3838
const ratingSelect = getByLabelText('Wonderful')
3939

40-
expect(initiallySelectedInput.checked).toBe(true)
41-
expect(ratingSelect.checked).toBe(false)
40+
expect(initiallySelectedInput).toBeChecked()
41+
expect(ratingSelect).not.toBeChecked()
4242

4343
await fireEvent.update(ratingSelect)
4444

45-
expect(ratingSelect.checked).toBe(true)
46-
expect(initiallySelectedInput.checked).toBe(false)
45+
expect(ratingSelect).toBeChecked()
46+
expect(initiallySelectedInput).not.toBeChecked()
4747

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

51-
expect(recommendInput.checked).toBe(false)
51+
expect(recommendInput).not.toBeChecked()
5252
await fireEvent.update(recommendInput)
53-
expect(recommendInput.checked).toBe(true)
53+
expect(recommendInput).toBeChecked()
5454

5555
// Make sure the submit button is enabled.
5656
expect(submitButton).toBeEnabled()

src/__tests__/functional.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {render} from '@testing-library/vue'
2+
import '@testing-library/jest-dom'
23
import FunctionalSFC from './components/FunctionalSFC'
34

45
const Functional = {
@@ -11,11 +12,11 @@ const Functional = {
1112
test('renders functional component', () => {
1213
const {getByText} = render(Functional)
1314

14-
getByText('Hi!')
15+
expect(getByText('Hi!')).toBeInTheDocument()
1516
})
1617

1718
test('renders functional SFC component', () => {
1819
const {getByText} = render(FunctionalSFC)
1920

20-
getByText('Hi!')
21+
expect(getByText('Hi!')).toBeInTheDocument()
2122
})

src/__tests__/slots.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ test('Card component', () => {
1919
})
2020

2121
// The default slot should render the template above with the scoped prop "content".
22-
getByText('Yay! Scoped content!')
22+
expect(getByText('Yay! Scoped content!')).toBeInTheDocument()
2323

2424
// Instead of the default slot's fallback content.
2525
expect(
2626
queryByText('Nothing used the Scoped content!'),
2727
).not.toBeInTheDocument()
2828

2929
// And the header and footer slots should be rendered with the given templates.
30-
getByText('HEADER')
31-
getByText('FOOTER')
30+
expect(getByText('HEADER')).toBeInTheDocument()
31+
expect(getByText('FOOTER')).toBeInTheDocument()
3232
})

src/__tests__/stopwatch.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ test('updates component state', async () => {
1212

1313
// Assert initial state.
1414
expect(elapsedTime).toHaveTextContent('0ms')
15-
getByText('Start')
15+
expect(getByText('Start')).toBeInTheDocument()
1616

1717
await fireEvent.click(startButton)
1818

19-
getByText('Stop')
19+
expect(getByText('Stop')).toBeInTheDocument()
2020

2121
// Wait for one tick of the event loop.
2222
await waitFor(() => {

src/__tests__/stubs.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import {render} from '@testing-library/vue'
2+
import '@testing-library/jest-dom'
23
import Stubs from './components/Stubs'
34

45
test('Form contains search button', () => {
56
const {getByText} = render(Stubs, {
67
stubs: ['FontAwesomeIcon'],
78
})
8-
getByText('Search now')
9+
expect(getByText('Search now')).toBeInTheDocument()
910
})

src/__tests__/vue-portal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test('portal', async () => {
2121
// wait until PortalVue has removed content from the source element
2222
// and moved it to the target one.
2323
await waitFor(() => {
24-
expect(getByTestId('portal')).toBeEmpty()
24+
expect(getByTestId('portal')).toBeEmptyDOMElement()
2525
})
2626

2727
expect(getByTestId('target')).toHaveTextContent(

src/__tests__/vuetify.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const renderWithVuetify = (component, options, callback) => {
3333
test('should set [data-app] attribute on outer most div', () => {
3434
const {container} = renderWithVuetify(VuetifyDemoComponent)
3535

36-
expect(container.getAttribute('data-app')).toEqual('true')
36+
expect(container).toHaveAttribute('data-app', 'true')
3737
})
3838

3939
test('renders a Vuetify-powered component', async () => {

src/__tests__/within.js

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ test('within() returns an object with all queries bound to the DOM node', () =>
2121
// within() returns queries bound to the provided DOM node, so the following
2222
// assertion passes. Notice how we are not using the getByText() function
2323
// provided by render(), but the one coming from within().
24+
// eslint-disable-next-line testing-library/prefer-explicit-assert
2425
within(divNode).getByText('repeated text')
2526

2627
// Here, proof that there's only one match for the specified text.

src/vue-testing-library.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable testing-library/no-wait-for-empty-callback */
12
import {createLocalVue, mount} from '@vue/test-utils'
23

34
import {

0 commit comments

Comments
 (0)