1 import { getIsSectionAvailable, getIsSubsectionAvailable } from './helper';
2 import type { SectionConfig, SubSectionConfig } from './interface';
4 describe('getIsSubsectionAvailable', () => {
5 it('returns true when `available` is undefined', () => {
6 const config: SubSectionConfig = {
10 const result = getIsSubsectionAvailable(config);
12 expect(result).toBe(true);
15 it('returns true when `available` is true', () => {
16 const config: SubSectionConfig = {
21 const result = getIsSubsectionAvailable(config);
23 expect(result).toBe(true);
26 it('returns false when `available` is false', () => {
27 const config: SubSectionConfig = {
32 const result = getIsSubsectionAvailable(config);
34 expect(result).toBe(false);
38 describe('getIsSectionAvailable', () => {
39 describe('available property', () => {
40 it('returns true when `available` is undefined', () => {
41 const config: SectionConfig = {
45 subsections: [{ id: '' }],
48 const result = getIsSectionAvailable(config);
50 expect(result).toBe(true);
53 it('returns true when `available` is true', () => {
54 const config: SectionConfig = {
59 subsections: [{ id: '' }],
62 const result = getIsSectionAvailable(config);
64 expect(result).toBe(true);
67 it('returns false when `available` is false', () => {
68 const config: SectionConfig = {
73 subsections: [{ id: '' }],
76 const result = getIsSectionAvailable(config);
78 expect(result).toBe(false);
82 describe('subsections prop', () => {
83 it('returns true when `subsections` is undefined', () => {
84 const config: SectionConfig = {
91 const result = getIsSectionAvailable(config);
93 expect(result).toBe(true);
96 it('returns true when all `subsections` are available', () => {
97 const config: SectionConfig = {
103 { id: '1', available: true },
104 { id: '2', available: true },
108 const result = getIsSectionAvailable(config);
110 expect(result).toBe(true);
113 it('returns true when some `subsections` are available', () => {
114 const config: SectionConfig = {
120 { id: '1', available: false },
121 { id: '2', available: true },
125 const result = getIsSectionAvailable(config);
127 expect(result).toBe(true);
130 it('returns false when no `subsections` are available', () => {
131 const config: SectionConfig = {
137 { id: '1', available: false },
138 { id: '2', available: false },
142 const result = getIsSectionAvailable(config);
144 expect(result).toBe(false);