vue-typeahead-bootstrap
Advanced tools
Comparing version 2.11.1 to 2.12.0
@@ -0,1 +1,5 @@ | ||
## 2.12.0 - 26 Aug 2021 | ||
- Revert localization changes | ||
- Update CI build targets | ||
## 2.11.1 - 23 Apr 2021 | ||
@@ -2,0 +6,0 @@ - Improve screen reader text support |
{ | ||
"name": "vue-typeahead-bootstrap", | ||
"version": "2.11.1", | ||
"version": "2.12.0", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "A typeahead/autocomplete component for Vue 2 using Bootstrap 4", |
@@ -28,2 +28,7 @@ import { mount } from '@vue/test-utils' | ||
text: 'Canadiana' | ||
}, | ||
{ | ||
id: 4, | ||
data: 'Canada (CA)', | ||
text: 'Canada (CA)' | ||
} | ||
@@ -46,67 +51,2 @@ ] | ||
it("Orders the results with text matches early in the hit's text first, not alphabetically", () => { | ||
const data = [ | ||
{ | ||
id: 0, | ||
data: 'all quiet on the western front', | ||
text: 'all quiet on the western front' | ||
}, | ||
{ | ||
id: 1, | ||
data: 'west side story', | ||
text: 'west side story' | ||
}, | ||
{ | ||
id: 2, | ||
data: 'western nevada', | ||
text: 'western nevada' | ||
} | ||
] | ||
wrapper = mount(VueTypeaheadBootstrapList, { | ||
propsData: { | ||
data: data, | ||
vbtUniqueId: 123456789 | ||
} | ||
}) | ||
expect(wrapper.vm.matchedItems.length).toBe(0) | ||
wrapper.setProps({ | ||
query: 'west' | ||
}) | ||
expect(wrapper.vm.matchedItems.length).toBe(3) | ||
let expectedOrder = ['west side story', 'western nevada', 'all quiet on the western front'] | ||
expect(wrapper.vm.matchedItems.map(item => item.text)).toEqual(expectedOrder) | ||
}) | ||
it("Orders the results with text matches early in the hit's text first, not alphabetically (with accents)", () => { | ||
const data = [ | ||
{ | ||
id: 0, | ||
data: 'le destin d\'amélie poulain', | ||
text: 'le destin d\'amélie poulain' | ||
}, | ||
{ | ||
id: 1, | ||
data: 'amélie poulain', | ||
text: 'amélie poulain' | ||
} | ||
] | ||
wrapper = mount(VueTypeaheadBootstrapList, { | ||
propsData: { | ||
data: data, | ||
vbtUniqueId: 123456789 | ||
} | ||
}) | ||
expect(wrapper.vm.matchedItems.length).toBe(0) | ||
wrapper.setProps({ | ||
query: 'amélie' | ||
}) | ||
expect(wrapper.vm.matchedItems.length).toBe(2) | ||
let expectedOrder = ['amélie poulain', 'le destin d\'amélie poulain'] | ||
expect(wrapper.vm.matchedItems.map(item => item.text)).toEqual(expectedOrder) | ||
}) | ||
it('Matches items when there is a query', async () => { | ||
@@ -118,4 +58,4 @@ expect(wrapper.vm.matchedItems.length).toBe(0) | ||
await wrapper.vm.$nextTick() | ||
expect(wrapper.vm.matchedItems.length).toBe(2) | ||
expect(wrapper.findAllComponents(VueTypeaheadBootstrapListItem).length).toBe(2) | ||
expect(wrapper.vm.matchedItems.length).toBe(3) | ||
expect(wrapper.findAllComponents(VueTypeaheadBootstrapListItem).length).toBe(3) | ||
wrapper.setProps({ | ||
@@ -125,4 +65,4 @@ query: 'Canada' | ||
await wrapper.vm.$nextTick() | ||
expect(wrapper.vm.matchedItems.length).toBe(1) | ||
expect(wrapper.findAllComponents(VueTypeaheadBootstrapListItem).length).toBe(1) | ||
expect(wrapper.vm.matchedItems.length).toBe(2) | ||
expect(wrapper.findAllComponents(VueTypeaheadBootstrapListItem).length).toBe(2) | ||
}) | ||
@@ -143,3 +83,3 @@ | ||
}) | ||
expect(wrapper.vm.matchedItems.length).toBe(2) | ||
expect(wrapper.vm.matchedItems.length).toBe(3) | ||
wrapper.setProps({ | ||
@@ -157,3 +97,3 @@ maxMatches: 1 | ||
await wrapper.vm.$nextTick() | ||
expect(wrapper.findAllComponents(VueTypeaheadBootstrapListItem).length).toBe(3) | ||
expect(wrapper.findAllComponents(VueTypeaheadBootstrapListItem).length).toBe(4) | ||
}) | ||
@@ -169,47 +109,10 @@ | ||
it('Highlights text matches correctly when the data contains accents and the query does not', async () => { | ||
it('Highlights text matches when query text contains regex escape characters', async () => { | ||
wrapper.setProps({ | ||
data: [ | ||
{ | ||
id: 0, | ||
data: 'amélie', | ||
text: 'amélie' | ||
} | ||
], | ||
query: 'ame' | ||
query: 'Canada (C' | ||
}) | ||
await wrapper.vm.$nextTick() | ||
expect(wrapper.findComponent(VueTypeaheadBootstrapListItem).vm.htmlText).toBe(`<span class='vbt-matched-text'>amé</span>lie`) | ||
expect(wrapper.findComponent(VueTypeaheadBootstrapListItem).vm.htmlText).toBe(`<span class='vbt-matched-text'>Canada (C</span>A)`) | ||
}) | ||
it('Highlights text matches correctly when the query contains accents and the data does not', async () => { | ||
wrapper.setProps({ | ||
data: [ | ||
{ | ||
id: 0, | ||
data: 'amelie', | ||
text: 'amelie' | ||
} | ||
], | ||
query: 'amé' | ||
}) | ||
await wrapper.vm.$nextTick() | ||
expect(wrapper.findComponent(VueTypeaheadBootstrapListItem).vm.htmlText).toBe(`<span class='vbt-matched-text'>ame</span>lie`) | ||
}) | ||
it('Highlights text matches correctly when the query contains accents and the data does not', async () => { | ||
wrapper.setProps({ | ||
data: [ | ||
{ | ||
id: 0, | ||
data: 'amelie', | ||
text: 'amelie' | ||
} | ||
], | ||
query: 'amé' | ||
}) | ||
await wrapper.vm.$nextTick() | ||
expect(wrapper.findComponent(VueTypeaheadBootstrapListItem).vm.htmlText).toBe(`<span class='vbt-matched-text'>ame</span>lie`) | ||
}) | ||
describe('providing accessible text for screen readers', () => { | ||
@@ -216,0 +119,0 @@ it('renders screen reader text if provided', async () => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1526478
15679