-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use new getOptionList by optionListId
- Loading branch information
Showing
25 changed files
with
262 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 0 additions & 41 deletions
41
...nd/app-development/features/appContentLibrary/utils/convertOptionListsToCodeLists.test.ts
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
frontend/app-development/features/appContentLibrary/utils/convertOptionListsToCodeLists.ts
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
...p-development/features/appContentLibrary/utils/convertOptionsListToCodeListResult.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import type { OnGetCodeListResult } from '@studio/content-library'; | ||
import { convertOptionsListToCodeListResult } from './convertOptionsListToCodeListResult'; | ||
import type { OptionsList } from 'app-shared/types/api/OptionsLists'; | ||
|
||
describe('convertOptionsListToCodeListResult', () => { | ||
it('converts option list to code list result correctly', () => { | ||
const optionList: OptionsList = [ | ||
{ label: 'Option 1', value: '1' }, | ||
{ label: 'Option 2', value: '2' }, | ||
]; | ||
const optionListId: string = 'optionListId'; | ||
const result: OnGetCodeListResult = convertOptionsListToCodeListResult( | ||
optionListId, | ||
optionList, | ||
false, | ||
); | ||
expect(result).toEqual({ | ||
codeListWithMetadata: { | ||
title: optionListId, | ||
codeList: [ | ||
{ label: 'Option 1', value: '1' }, | ||
{ label: 'Option 2', value: '2' }, | ||
], | ||
}, | ||
isError: false, | ||
}); | ||
}); | ||
|
||
it('sets isError to true in result when getOptionsList returns error', () => { | ||
const optionListId: string = 'optionListId'; | ||
const result: OnGetCodeListResult = convertOptionsListToCodeListResult( | ||
optionListId, | ||
undefined, | ||
false, | ||
); | ||
expect(result).toEqual({ | ||
codeListWithMetadata: { | ||
title: optionListId, | ||
codeList: undefined, | ||
}, | ||
isError: false, | ||
}); | ||
}); | ||
|
||
it('returns a result with empty code list array when the input option list is empty', () => { | ||
const optionList: OptionsList = []; | ||
const optionListId: string = 'optionListId'; | ||
const result: OnGetCodeListResult = convertOptionsListToCodeListResult( | ||
optionListId, | ||
optionList, | ||
false, | ||
); | ||
expect(result).toEqual({ | ||
codeListWithMetadata: { title: optionListId, codeList: [] }, | ||
isError: false, | ||
}); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
...nd/app-development/features/appContentLibrary/utils/convertOptionsListToCodeListResult.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { OptionsList } from 'app-shared/types/api/OptionsLists'; | ||
import type { OnGetCodeListResult } from '@studio/content-library'; | ||
|
||
export const convertOptionsListToCodeListResult = ( | ||
optionListId: string, | ||
optionsList: OptionsList, | ||
isError: boolean, | ||
): OnGetCodeListResult => { | ||
const codeListWithMetadata = { title: optionListId, codeList: optionsList }; | ||
return { | ||
codeListWithMetadata: codeListWithMetadata, | ||
isError: isError, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 7 additions & 5 deletions
12
frontend/libs/studio-content-library/mocks/mockPagesConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.