From 2a462c44c36da608c1248f0a80796c88b4d2799b Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Tue, 28 May 2024 15:31:57 +0200 Subject: [PATCH] refactor: Fix linter issues on test case files Signed-off-by: Ferdinand Thiessen --- tests/.eslintrc.js | 4 +- .../NcHighlight/NcHighlight.spec.js | 42 ++++---- .../components/NcRichText/NcRichText.spec.js | 96 +++++++++---------- tests/unit/utils/FindRanges.spec.js | 20 ++-- 4 files changed, 81 insertions(+), 81 deletions(-) diff --git a/tests/.eslintrc.js b/tests/.eslintrc.js index 22f33a51d5..bb9eff9eba 100644 --- a/tests/.eslintrc.js +++ b/tests/.eslintrc.js @@ -1,9 +1,9 @@ module.exports = { env: { jest: true, - "cypress/globals": true + 'cypress/globals': true, }, extends: [ - "plugin:cypress/recommended" + 'plugin:cypress/recommended', ], } diff --git a/tests/unit/components/NcHighlight/NcHighlight.spec.js b/tests/unit/components/NcHighlight/NcHighlight.spec.js index 764c6bdff7..d0b3e44d2a 100644 --- a/tests/unit/components/NcHighlight/NcHighlight.spec.js +++ b/tests/unit/components/NcHighlight/NcHighlight.spec.js @@ -33,15 +33,15 @@ describe('NcHighlight.vue', () => { text: 'Highlight me', search: 'me', highlight: [ - { start: 3, end: 1}, - { start: 5, end: 7}, - ] + { start: 3, end: 1 }, + { start: 5, end: 7 }, + ], }, }) expect(wrapper.vm.ranges).toEqual([ - {start: 1, end: 3}, - {start: 5, end: 7}, + { start: 1, end: 3 }, + { start: 5, end: 7 }, ]) }) @@ -55,13 +55,13 @@ describe('NcHighlight.vue', () => { { start: 1, end: 3 }, { start: 5, end: 7 }, { start: 20, end: 25 }, - ] + ], }, }) expect(wrapper.vm.ranges).toEqual([ - {start: 1, end: 3}, - {start: 5, end: 7}, + { start: 1, end: 3 }, + { start: 5, end: 7 }, ]) }) @@ -77,15 +77,15 @@ describe('NcHighlight.vue', () => { { start: 5, end: 7 }, { start: 10, end: 25 }, { start: 20, end: 25 }, - ] + ], }, }) expect(wrapper.vm.ranges).toEqual([ - {start: 0, end: 1}, - {start: 3, end: 3}, - {start: 5, end: 7}, - {start: 10, end: 12}, + { start: 0, end: 1 }, + { start: 3, end: 3 }, + { start: 5, end: 7 }, + { start: 10, end: 12 }, ]) }) @@ -101,15 +101,15 @@ describe('NcHighlight.vue', () => { { start: 10, end: 25 }, { start: 5, end: 7 }, { start: 3, end: 3 }, - ] + ], }, }) expect(wrapper.vm.ranges).toEqual([ - {start: 0, end: 1}, - {start: 3, end: 3}, - {start: 5, end: 7}, - {start: 10, end: 12}, + { start: 0, end: 1 }, + { start: 3, end: 3 }, + { start: 5, end: 7 }, + { start: 10, end: 12 }, ]) }) @@ -127,13 +127,13 @@ describe('NcHighlight.vue', () => { { start: 7, end: 9 }, { start: 20, end: 25 }, { start: -10, end: -2 }, - ] + ], }, }) expect(wrapper.vm.ranges).toEqual([ - {start: 0, end: 3}, - {start: 5, end: 12}, + { start: 0, end: 3 }, + { start: 5, end: 12 }, ]) }) }) diff --git a/tests/unit/components/NcRichText/NcRichText.spec.js b/tests/unit/components/NcRichText/NcRichText.spec.js index 4c2c5d97fe..f460a79955 100644 --- a/tests/unit/components/NcRichText/NcRichText.spec.js +++ b/tests/unit/components/NcRichText/NcRichText.spec.js @@ -1,46 +1,46 @@ import { mount } from '@vue/test-utils' import NcRichText from '../../../../src/components/NcRichText/NcRichText.vue' -describe('Foo', () => { - it('renders a message and responds correctly to props changes', async() => { +describe('NcRichText', () => { + it('renders a message and responds correctly to props changes', async () => { const wrapper = mount(NcRichText, { propsData: { - text: 'Test {placeholder}' - } + text: 'Test {placeholder}', + }, }) expect(wrapper.text()).toEqual('Test {placeholder}') }) - it('properly inserts a child component', async() => { + it('properly inserts a child component', async () => { const MyComponent = { name: 'MyComponent', render: (createElement) => { return createElement('div', 'MYCOMPONENT') - } + }, } const wrapper = mount(NcRichText, { propsData: { text: 'Test {placeholder}', arguments: { placeholder: { - component: MyComponent - } - } - } + component: MyComponent, + }, + }, + }, }) expect(wrapper.text()).toEqual('Test MYCOMPONENT') expect(wrapper.findComponent(MyComponent).exists()).toBe(true) }) - it('properly inserts a child component with props', async() => { + it('properly inserts a child component with props', async () => { const MyComponent = { name: 'MyComponent', props: ['username'], render: (createElement) => { return createElement('div', 'MYCOMPONENT') - } + }, } const wrapper = mount(NcRichText, { propsData: { @@ -49,11 +49,11 @@ describe('Foo', () => { placeholder: { component: MyComponent, props: { - username: 'Jane' - } - } - } - } + username: 'Jane', + }, + }, + }, + }, }) expect(wrapper.text()).toEqual('Test MYCOMPONENT') @@ -71,105 +71,105 @@ describe('Foo', () => { ['{placeholderA}', { placeholderA: 'A', placeholderB: 'B' }, 'A'], ['{placeholderA} {placeholderB}', { placeholderA: 'A', placeholderB: 'B' }, 'A B'], ['Test {placeholderA} {placeholderB}', { placeholderA: 'A', placeholderB: 'B' }, 'Test A B'], - ['Test {placeholderA} {placeholderA} {placeholderB}', { placeholderA: 'A', placeholderB: 'B' }, 'Test A A B'] + ['Test {placeholderA} {placeholderA} {placeholderB}', { placeholderA: 'A', placeholderB: 'B' }, 'Test A A B'], ])('text: %s', (text, attrs, result) => { const wrapper = mount(NcRichText, { propsData: { text, - arguments: attrs - } + arguments: attrs, + }, }) expect(wrapper.text()).toEqual(result) }) - it('properly inserts a link', async() => { + it('properly inserts a link', async () => { const wrapper = mount(NcRichText, { propsData: { text: 'Testwith a link to https://example.com - go visit it', - autolink: true - } + autolink: true, + }, }) expect(wrapper.text()).toEqual('Testwith a link to https://example.com - go visit it') expect(wrapper.find('a').attributes('href')).toEqual('https://example.com') }) - it('properly inserts a newline', async() => { + it('properly inserts a newline', async () => { const wrapper = mount(NcRichText, { propsData: { text: 'Testwith a link to https://example.com \n go visit it', - autolink: true - } + autolink: true, + }, }) expect(wrapper.text()).toEqual('Testwith a link to https://example.com \n go visit it') expect(wrapper.find('a').attributes('href')).toEqual('https://example.com') - expect(wrapper.html()).toContain(`\n go visit it`) + expect(wrapper.html()).toContain('\n go visit it') }) - it('properly inserts a link with brackets', async() => { + it('properly inserts a link with brackets', async () => { const wrapper = mount(NcRichText, { propsData: { text: 'Test with a link to (https://example.com) - go visit it', - autolink: true - } + autolink: true, + }, }) expect(wrapper.text()).toEqual('Test with a link to (https://example.com) - go visit it') expect(wrapper.find('a').attributes('href')).toEqual('https://example.com') }) - it('properly inserts a link containing brackets', async() => { + it('properly inserts a link containing brackets', async () => { const wrapper = mount(NcRichText, { propsData: { text: 'Test with a link to (https://example.com/Link%20(Sub)) - go visit it', autolink: true, - } + }, }) expect(wrapper.text()).toEqual('Test with a link to (https://example.com/Link%20(Sub)) - go visit it') expect(wrapper.find('a').attributes('href')).toEqual('https://example.com/Link%20(Sub)') }) - it('properly inserts a link containing brackets with markdown', async() => { + it('properly inserts a link containing brackets with markdown', async () => { const wrapper = mount(NcRichText, { propsData: { text: 'Test with a link to (https://example.com/Link%20(Sub)) - go visit it', autolink: true, useMarkdown: true, - } + }, }) expect(wrapper.text()).toEqual('Test with a link to (https://example.com/Link%20(Sub)) - go visit it') expect(wrapper.find('a').attributes('href')).toEqual('https://example.com/Link%20(Sub)') }) - it('properly recognizes an url with a custom port and inserts a link', async() => { + it('properly recognizes an url with a custom port and inserts a link', async () => { const wrapper = mount(NcRichText, { propsData: { text: 'Testwith a link to https://example.com:444 - go visit it', - autolink: true - } + autolink: true, + }, }) expect(wrapper.text()).toEqual('Testwith a link to https://example.com:444 - go visit it') expect(wrapper.find('a').attributes('href')).toEqual('https://example.com:444') }) - it('properly recognizes an url with an IP address and inserts a link', async() => { + it('properly recognizes an url with an IP address and inserts a link', async () => { const wrapper = mount(NcRichText, { propsData: { text: 'Testwith a link to https://127.0.0.1/status.php - go visit it', - autolink: true - } + autolink: true, + }, }) expect(wrapper.text()).toEqual('Testwith a link to https://127.0.0.1/status.php - go visit it') expect(wrapper.find('a').attributes('href')).toEqual('https://127.0.0.1/status.php') }) - it('properly formats markdown', async() => { + it('properly formats markdown', async () => { const wrapper = mount(NcRichText, { propsData: { text: '**Testwith** a link *to* [Link](https://example:1337) - go visit it', autolink: false, - useMarkdown: true - } + useMarkdown: true, + }, }) expect(wrapper.text()).toEqual('Testwith a link to Link - go visit it') expect(wrapper.find('a').attributes('href')).toEqual('https://example:1337') @@ -177,18 +177,18 @@ describe('Foo', () => { expect(wrapper.find('em').text()).toEqual('to') }) - it('formats markdown is disabled', async() => { + it('formats markdown is disabled', async () => { const wrapper = mount(NcRichText, { propsData: { text: '**Testwith** a ~~link~~ *to* [Link](https://example:1337) - go visit it', autolink: true, - useMarkdown: false - } + useMarkdown: false, + }, }) expect(wrapper.text()).toEqual('**Testwith** a ~~link~~ *to* [Link](https://example:1337) - go visit it') }) - it('formats interactive checkbox with extended markdown', async() => { + it('formats interactive checkbox with extended markdown', async () => { const wrapper = mount(NcRichText, { propsData: { text: '- [ ] task item', @@ -197,7 +197,7 @@ describe('Foo', () => { }, }) expect(wrapper.text()).toEqual('task item') - const checkbox = wrapper.findComponent({name: 'NcCheckboxRadioSwitch'}) + const checkbox = wrapper.findComponent({ name: 'NcCheckboxRadioSwitch' }) expect(checkbox.exists()).toBeTruthy() await checkbox.vm.$emit('update:checked', true) expect(wrapper.emitted()['interact:todo']).toBeTruthy() diff --git a/tests/unit/utils/FindRanges.spec.js b/tests/unit/utils/FindRanges.spec.js index 4ce0719f3a..8e23a4b6e4 100644 --- a/tests/unit/utils/FindRanges.spec.js +++ b/tests/unit/utils/FindRanges.spec.js @@ -20,7 +20,7 @@ * */ -import FindRanges from '../../../src/utils/FindRanges' +import FindRanges from '../../../src/utils/FindRanges.js' describe('FindRanges.js', () => { 'use strict' @@ -30,7 +30,7 @@ describe('FindRanges.js', () => { const ranges = FindRanges('ananas', 'anan') expect(ranges).toEqual([ - {start: 0, end: 4}, + { start: 0, end: 4 }, ]) }) @@ -38,16 +38,16 @@ describe('FindRanges.js', () => { const ranges1 = FindRanges('ananas', 'an') expect(ranges1).toEqual([ - {start: 0, end: 2}, - {start: 2, end: 4}, + { start: 0, end: 2 }, + { start: 2, end: 4 }, ]) const ranges2 = FindRanges('ananas', 'a') expect(ranges2).toEqual([ - {start: 0, end: 1}, - {start: 2, end: 3}, - {start: 4, end: 5}, + { start: 0, end: 1 }, + { start: 2, end: 3 }, + { start: 4, end: 5 }, ]) }) @@ -55,14 +55,14 @@ describe('FindRanges.js', () => { const ranges1 = FindRanges('ananas', 'ana') expect(ranges1).toEqual([ - {start: 0, end: 3}, + { start: 0, end: 3 }, ]) const ranges2 = FindRanges('oooo', 'oo') expect(ranges2).toEqual([ - {start: 0, end: 2}, - {start: 2, end: 4}, + { start: 0, end: 2 }, + { start: 2, end: 4 }, ]) }) })