import * as stubData from './stub-data' import type { Collection } from './types' import { selectionStatus } from './selection-status' describe('selectionStatus', () => { let collection: Collection describe('basic', () => { beforeEach(() => { collection = stubData.basic }) it('should return all if id is selected', () => { expect(selectionStatus(collection, new Set(['1']), '1')).toBe('all') }) it('should return none if id is not selected', () => { expect(selectionStatus(collection, new Set(['1']), '2')).toBe( 'none' ) }) }) describe('tree', () => { beforeEach(() => { collection = stubData.tree }) it('should return all if id is selected (parent)', () => { expect(selectionStatus(collection, new Set(['1']), '1')).toBe('all') }) it('should return all if id is selected (child)', () => { expect(selectionStatus(collection, new Set(['2']), '2')).toBe('all') }) it('should return none if id is not selected', () => { expect(selectionStatus(collection, new Set(['1']), '2')).toBe( 'none' ) }) }) describe('group', () => { beforeEach(() => { collection = stubData.group }) it('should return all if all children are selected', () => { expect( selectionStatus(collection, new Set(['1', '4']), 'group-1') ).toBe('all') }) it('should return all if all filtered children are selected', () => { expect( selectionStatus( collection, new Set(['1']), 'group-1', new Set(['1']) ) ).toBe('all') }) it('should return some if some children are selected', () => { expect(selectionStatus(collection, new Set(['1']), 'group-1')).toBe( 'some' ) }) it('should return none if no children are selected', () => { expect(selectionStatus(collection, new Set(['3']), 'group-1')).toBe( 'none' ) }) }) describe('groupedTree', () => { beforeEach(() => { collection = stubData.groupedTree }) it('should return all if all children are selected', () => { expect( selectionStatus(collection, new Set(['1', '2']), 'group-1') ).toBe('all') }) it('should return some if some children are selected (direct child)', () => { expect(selectionStatus(collection, new Set(['1']), 'group-1')).toBe( 'some' ) }) it('should return some if some children are selected (descendant)', () => { expect(selectionStatus(collection, new Set(['2']), 'group-1')).toBe( 'some' ) }) it('should return none if no children are selected', () => { expect(selectionStatus(collection, new Set(['3']), 'group-1')).toBe( 'none' ) }) }) })