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

refactor: Fix linter issues on test case files #5646

Merged
merged 1 commit into from
May 28, 2024
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
4 changes: 2 additions & 2 deletions tests/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module.exports = {
env: {
jest: true,
"cypress/globals": true
'cypress/globals': true,
},
extends: [
"plugin:cypress/recommended"
'plugin:cypress/recommended',
],
}
42 changes: 21 additions & 21 deletions tests/unit/components/NcHighlight/NcHighlight.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
])
})

Expand All @@ -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 },
])
})

Expand All @@ -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 },
])
})

Expand All @@ -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 },
])
})

Expand All @@ -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 },
])
})
})
Expand Down
96 changes: 48 additions & 48 deletions tests/unit/components/NcRichText/NcRichText.spec.js
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -49,11 +49,11 @@ describe('Foo', () => {
placeholder: {
component: MyComponent,
props: {
username: 'Jane'
}
}
}
}
username: 'Jane',
},
},
},
},
})

expect(wrapper.text()).toEqual('Test MYCOMPONENT')
Expand All @@ -71,124 +71,124 @@ 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')
expect(wrapper.find('strong').text()).toEqual('Testwith')
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',
Expand All @@ -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()
Expand Down
Loading
Loading