Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add missing test case for sorting equal values and ESLint warning #1014

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion __mocks__/@nextcloud/router.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/**
/*!
* SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

/**
* @param {string} path The path
*/
export const generateRemoteUrl = (path) => `https://localhost/${path}`
18 changes: 18 additions & 0 deletions __tests__/utils/sorting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,22 @@ describe('orderBy', () => {
).map((v) => v.text),
).toEqual(['monday', 'tuesday', 'wednesday'])
})

test('sort with equal values', () => {
const array = [
{ text: 'Dienstag', value: 2 },
{ text: 'Monday', value: 1 },
{ text: 'Wednesday', value: 3 },
{ text: 'Tuesday', value: 2 },
]

const ordered = orderBy(
array,
[(v) => v.value],
)

expect(ordered[0].text).toBe('Monday')
expect(ordered[3].text).toBe('Wednesday')
// the rest can be in any order
})
})
Loading