Sort index views by id
This commit is contained in:
@@ -86,7 +86,10 @@ const errorMessage = ref('');
|
||||
// Initialize currentView from the store's default setting for asistencias
|
||||
const currentView = ref(ui.defaultViewAsistencias);
|
||||
|
||||
const asistenciasList = computed(() => asistenciasStore.asistencias);
|
||||
// Show asistencias ordered by id descending
|
||||
const asistenciasList = computed(() =>
|
||||
[...(asistenciasStore.asistencias || [])].sort((a, b) => b.id - a.id)
|
||||
);
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
|
||||
@@ -85,7 +85,8 @@ describe('AsistenciasIndex.vue', () => {
|
||||
|
||||
|
||||
expect(wrapper.findComponent({ name: 'TablaAsistencias' }).exists()).toBe(true)
|
||||
expect(wrapper.findComponent({ name: 'TablaAsistencias' }).props('asistencias')).toEqual(asistenciasStoreMock.asistencias)
|
||||
const expected = [...asistenciasStoreMock.asistencias].sort((a, b) => b.id - a.id)
|
||||
expect(wrapper.findComponent({ name: 'TablaAsistencias' }).props('asistencias')).toEqual(expected)
|
||||
expect(wrapper.findComponent({ name: 'CardAsistencia' }).exists()).toBe(false)
|
||||
})
|
||||
|
||||
@@ -99,8 +100,9 @@ describe('AsistenciasIndex.vue', () => {
|
||||
await wrapper.vm.$nextTick()
|
||||
|
||||
const cardWrappers = wrapper.findAllComponents({ name: 'CardAsistencia' })
|
||||
expect(cardWrappers.length).toBe(asistenciasStoreMock.asistencias.length)
|
||||
expect(cardWrappers[0].props('asistencia')).toEqual(asistenciasStoreMock.asistencias[0])
|
||||
const expected = [...asistenciasStoreMock.asistencias].sort((a, b) => b.id - a.id)
|
||||
expect(cardWrappers.length).toBe(expected.length)
|
||||
expect(cardWrappers[0].props('asistencia')).toEqual(expected[0])
|
||||
expect(wrapper.findComponent({ name: 'TablaAsistencias' }).exists()).toBe(false)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user