forked from Ivasoft/geovisio-website
Fix/sort sequences
This commit is contained in:
@@ -61,7 +61,6 @@ describe('Template', () => {
|
||||
expect(axios.get).toHaveBeenCalledWith('api/users/me/catalog')
|
||||
expect(wrapper.vm.userSequences).toEqual([])
|
||||
expect(wrapper.html()).contains('general.header.contribute_text')
|
||||
expect(wrapper.html()).contains('path="/partager-des-photos"')
|
||||
})
|
||||
|
||||
it('should render the view with a loader loading', async () => {
|
||||
@@ -77,7 +76,6 @@ describe('Template', () => {
|
||||
expect(axios.get).toHaveBeenCalledWith('api/users/me/catalog')
|
||||
expect(wrapper.vm.userSequences).toEqual([])
|
||||
expect(wrapper.html()).contains('general.header.contribute_text')
|
||||
expect(wrapper.html()).contains('path="/partager-des-photos"')
|
||||
})
|
||||
|
||||
it('should render the view with a sequence in the list', async () => {
|
||||
@@ -99,43 +97,39 @@ describe('Template', () => {
|
||||
})
|
||||
|
||||
describe('Methods', () => {
|
||||
describe('sortElements', () => {
|
||||
const mockResponseSequencesToSort = [
|
||||
{
|
||||
href: 'https://my-link',
|
||||
id: 'my-id',
|
||||
rel: 'child',
|
||||
'stats:items': { count: 16 },
|
||||
title: 'za sequence 1',
|
||||
extent: {
|
||||
temporal: {
|
||||
interval: [
|
||||
['2030-09-22T08:03:08+00:00', '2022-09-22T08:03:08+00:00']
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
href: 'https://my-link',
|
||||
id: 'my-id',
|
||||
rel: 'child',
|
||||
'stats:items': { count: 2 },
|
||||
title: 'ma sequence 1',
|
||||
extent: {
|
||||
temporal: {
|
||||
interval: [
|
||||
['2022-09-22T08:03:08+00:00', '2022-09-22T08:03:08+00:00']
|
||||
]
|
||||
}
|
||||
const mockResponseSequencesToSort = [
|
||||
{
|
||||
href: 'https://my-link',
|
||||
id: 'my-id',
|
||||
rel: 'child',
|
||||
'stats:items': { count: 16 },
|
||||
title: 'za sequence 1',
|
||||
extent: {
|
||||
temporal: {
|
||||
interval: [['2030-09-22T08:03:08+00:00', '2022-09-22T08:03:08+00:00']]
|
||||
}
|
||||
}
|
||||
]
|
||||
beforeEach(async () => {
|
||||
await axios.get.mockReturnValue({
|
||||
data: { links: mockResponseSequencesToSort }
|
||||
})
|
||||
await flushPromises()
|
||||
},
|
||||
{
|
||||
href: 'https://my-link',
|
||||
id: 'my-id',
|
||||
rel: 'child',
|
||||
'stats:items': { count: 2 },
|
||||
title: 'ma sequence 1',
|
||||
extent: {
|
||||
temporal: {
|
||||
interval: [['2022-09-22T08:03:08+00:00', '2022-09-22T08:03:08+00:00']]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
beforeEach(async () => {
|
||||
await axios.get.mockReturnValue({
|
||||
data: { links: mockResponseSequencesToSort }
|
||||
})
|
||||
await flushPromises()
|
||||
})
|
||||
describe('sortAlpha', () => {
|
||||
it('should should sort sequences by title', async () => {
|
||||
const wrapper = shallowMount(MySequencesView, {
|
||||
global: {
|
||||
@@ -150,17 +144,19 @@ describe('Methods', () => {
|
||||
})
|
||||
wrapper.vm.isLoading = false
|
||||
await wrapper.vm.$nextTick()
|
||||
const spy = vi.spyOn(wrapper.vm, 'sortElements')
|
||||
const spy = vi.spyOn(wrapper.vm, 'sortAlpha')
|
||||
const buttonWrapper = wrapper.findComponent(
|
||||
'[data-test="button-sort-title"]'
|
||||
)
|
||||
await buttonWrapper.vm.$emit('trigger')
|
||||
|
||||
expect(spy).toHaveBeenCalledWith('alpha')
|
||||
expect(spy).toHaveBeenCalledWith('title')
|
||||
expect(wrapper.vm.userSequences[0]).toEqual(
|
||||
mockResponseSequencesToSort[1]
|
||||
)
|
||||
})
|
||||
})
|
||||
describe('sortNum', () => {
|
||||
it('should should sort sequences by number of pictures', async () => {
|
||||
const wrapper = shallowMount(MySequencesView, {
|
||||
global: {
|
||||
@@ -175,7 +171,7 @@ describe('Methods', () => {
|
||||
})
|
||||
wrapper.vm.isLoading = false
|
||||
await wrapper.vm.$nextTick()
|
||||
const spy = vi.spyOn(wrapper.vm, 'sortElements')
|
||||
const spy = vi.spyOn(wrapper.vm, 'sortNum')
|
||||
const buttonWrapper = wrapper.findComponent(
|
||||
'[data-test="button-sort-number"]'
|
||||
)
|
||||
@@ -200,7 +196,7 @@ describe('Methods', () => {
|
||||
})
|
||||
wrapper.vm.isLoading = false
|
||||
await wrapper.vm.$nextTick()
|
||||
const spy = vi.spyOn(wrapper.vm, 'sortElements')
|
||||
const spy = vi.spyOn(wrapper.vm, 'sortNum')
|
||||
const buttonWrapper = wrapper.findComponent(
|
||||
'[data-test="button-sort-date"]'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user