@instructure/quiz-interactions
Version:
A React UI component Library for quiz interaction types.
24 lines (20 loc) • 756 B
JavaScript
import {describe, expect, it} from 'vitest'
import {getSortedCategories} from '../utils'
describe('getSortedCategories', () => {
const categories = {
1: 'one',
4: 'four',
2: 'two',
3: 'three',
}
const categoryOrder = [4, 3, 2, 1]
it('sorts the categories based on categoryOrder', () => {
const sortedCategories = getSortedCategories(categories, categoryOrder)
expect(sortedCategories).toEqual(['four', 'three', 'two', 'one'])
})
it('still returns a list of all the categories when no order provided', () => {
const sortedCategories = getSortedCategories(categories)
expect(sortedCategories).toHaveLength(4)
expect(sortedCategories).toEqual(expect.arrayContaining(['one', 'two', 'three', 'four']))
})
})