Skip to content

Commit

Permalink
refactor: Fix linter issues on test case files
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>

[skip ci]
  • Loading branch information
susnux authored and backportbot[bot] committed May 28, 2024
1 parent 87bbed6 commit c243b13
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 72 deletions.
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 @@ -35,15 +35,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 @@ -57,13 +57,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 @@ -79,15 +79,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 @@ -103,15 +103,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 @@ -129,13 +129,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
84 changes: 42 additions & 42 deletions tests/unit/components/NcRichText/NcRichText.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Foo', () => {
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: () => {
Expand All @@ -27,17 +27,17 @@ describe('Foo', () => {
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'],
Expand All @@ -52,11 +52,11 @@ describe('Foo', () => {
placeholder: {
component: MyComponent,
props: {
username: 'Jane'
}
}
}
}
username: 'Jane',
},
},
},
},
})

expect(wrapper.text()).toEqual('Test MYCOMPONENT')
Expand All @@ -74,124 +74,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, {
props: {
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, {
props: {
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, {
props: {
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, {
props: {
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, {
props: {
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, {
props: {
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, {
props: {
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, {
props: {
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, {
props: {
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, {
props: {
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, {
props: {
text: '- [ ] task item',
Expand All @@ -200,7 +200,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:modelValue', true)
expect(wrapper.emitted()['interact:todo']).toBeTruthy()
Expand Down
18 changes: 9 additions & 9 deletions tests/unit/utils/FindRanges.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,39 +32,39 @@ describe('FindRanges.js', () => {
const ranges = FindRanges('ananas', 'anan')

expect(ranges).toEqual([
{start: 0, end: 4},
{ start: 0, end: 4 },
])
})

it('should find all non-overlapping ranges', () => {
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 },
])
})

it('should only find first occurence of overlapping ranges', () => {
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 },
])
})
})
Expand Down

0 comments on commit c243b13

Please sign in to comment.