-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(j-s): Add punishment type tag column in prison cases overview ta…
…ble (#17285) * feat(j-s): js web utility array function * feat(j-s): add punishment type columns in prison cases overview * fix(j-s): fix sort by punishement type * fix(j-s): format and clean-up * fix(j-s): Address auto code review feedback * fix(j-s): fix tests * chore: nx format:write update dirty files --------- Co-authored-by: andes-it <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
b3d7757
commit b76b7dd
Showing
10 changed files
with
150 additions
and
1 deletion.
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
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
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
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,45 @@ | ||
import { isEmptyArray, isNonEmptyArray, isPresentArray } from './arrayHelpers' | ||
|
||
describe('arrayHelpers', () => { | ||
describe('isPresentArray', () => { | ||
const testCases = [ | ||
{ input: undefined, expected: false }, | ||
{ input: null, expected: false }, | ||
{ input: [], expected: true }, | ||
{ input: [1], expected: true }, | ||
] | ||
testCases.forEach(({ input, expected }) => { | ||
it(`should return ${expected} for input ${input}`, () => { | ||
expect(isPresentArray(input)).toBe(expected) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('isEmptyArray', () => { | ||
const testCases = [ | ||
{ input: undefined, expected: false }, | ||
{ input: null, expected: false }, | ||
{ input: [], expected: true }, | ||
{ input: [1], expected: false }, | ||
] | ||
testCases.forEach(({ input, expected }) => { | ||
it(`should return ${expected} for input ${input}`, () => { | ||
expect(isEmptyArray(input)).toBe(expected) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('isNonEmptyArray', () => { | ||
const testCases = [ | ||
{ input: undefined, expected: false }, | ||
{ input: null, expected: false }, | ||
{ input: [], expected: false }, | ||
{ input: [1], expected: true }, | ||
] | ||
testCases.forEach(({ input, expected }) => { | ||
it(`should return ${expected} for input ${input}`, () => { | ||
expect(isNonEmptyArray(input)).toBe(expected) | ||
}) | ||
}) | ||
}) | ||
}) |
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,8 @@ | ||
export const isPresentArray = <T>(arr: T[] | undefined | null): arr is T[] => | ||
arr !== undefined && arr !== null && Array.isArray(arr) | ||
|
||
export const isEmptyArray = <T>(arr: T[] | undefined | null): arr is T[] => | ||
isPresentArray(arr) && arr?.length === 0 | ||
|
||
export const isNonEmptyArray = <T>(arr: T[] | undefined | null): arr is T[] => | ||
isPresentArray(arr) && arr.length > 0 |