From 109c7d30a32ef650609c949d680644801a7e3dd2 Mon Sep 17 00:00:00 2001 From: callmeroot Date: Wed, 21 Aug 2024 10:51:12 +0530 Subject: [PATCH] updated test suite --- lib/KTable/useSorting/__tests__/index.spec.js | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/KTable/useSorting/__tests__/index.spec.js b/lib/KTable/useSorting/__tests__/index.spec.js index 74f825b68..a7d08b6e0 100644 --- a/lib/KTable/useSorting/__tests__/index.spec.js +++ b/lib/KTable/useSorting/__tests__/index.spec.js @@ -1,5 +1,4 @@ import { ref } from '@vue/composition-api'; -import _ from 'lodash'; import useSorting, { SORT_ORDER_ASC, SORT_ORDER_DESC, @@ -41,18 +40,30 @@ describe('useSorting', () => { handleSort(0); // Sort by 'Name' - expect(sortedRows.value).toEqual(_.orderBy(rows.value, [row => row[0]], [SORT_ORDER_ASC])); + expect(sortedRows.value).toEqual([ + ['Alice', 28, new Date(1992, 8, 10)], + ['Jane', 25, new Date(1995, 10, 20)], + ['John', 30, new Date(1990, 5, 15)], + ]); }); it('should sort rows by numeric column in ascending and descending order', () => { const { handleSort, sortedRows, sortOrder } = useSorting(headers, rows, useLocalSorting); handleSort(1); // Sort by 'Age' - expect(sortedRows.value).toEqual(_.orderBy(rows.value, [row => row[1]], [SORT_ORDER_ASC])); + expect(sortedRows.value).toEqual([ + ['Jane', 25, new Date(1995, 10, 20)], + ['Alice', 28, new Date(1992, 8, 10)], + ['John', 30, new Date(1990, 5, 15)], + ]); expect(sortOrder.value).toBe(SORT_ORDER_ASC); handleSort(1); // Sort by 'Age' again to toggle order - expect(sortedRows.value).toEqual(_.orderBy(rows.value, [row => row[1]], [SORT_ORDER_DESC])); + expect(sortedRows.value).toEqual([ + ['John', 30, new Date(1990, 5, 15)], + ['Alice', 28, new Date(1992, 8, 10)], + ['Jane', 25, new Date(1995, 10, 20)], + ]); expect(sortOrder.value).toBe(SORT_ORDER_DESC); }); @@ -60,7 +71,11 @@ describe('useSorting', () => { const { handleSort, sortedRows } = useSorting(headers, rows, useLocalSorting); handleSort(2); // Sort by 'Birthdate' - expect(sortedRows.value).toEqual(_.orderBy(rows.value, [row => row[2]], [SORT_ORDER_ASC])); + expect(sortedRows.value).toEqual([ + ['John', 30, new Date(1990, 5, 15)], + ['Alice', 28, new Date(1992, 8, 10)], + ['Jane', 25, new Date(1995, 10, 20)], + ]); }); it('should not sort rows when sorting by a column with dataType "others"', () => {