Skip to content

Commit aa871b5

Browse files
committed
getOperationNotPermittedMessage: make all arguments required
- Fix tests
1 parent ee23a37 commit aa871b5

2 files changed

Lines changed: 30 additions & 11 deletions

File tree

packages/components/src/internal/components/samples/utils.test.ts

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -266,21 +266,40 @@ describe('getOperationNotAllowedMessage', () => {
266266

267267
describe('getOperationNotPermittedMessage', () => {
268268
test('no statusData', () => {
269-
expect(getOperationNotPermittedMessage(undefined)).toBeNull();
269+
expect(getOperationNotPermittedMessage(undefined, 'sample', 'samples', 1)).toBeNull();
270270
});
271271

272272
test('no notPermitted', () => {
273-
expect(getOperationNotPermittedMessage(new OperationConfirmationData({ notPermitted: undefined }))).toBeNull();
274-
expect(getOperationNotPermittedMessage(new OperationConfirmationData({ notPermitted: [] }))).toBeNull();
273+
expect(
274+
getOperationNotPermittedMessage(
275+
new OperationConfirmationData({ notPermitted: undefined }),
276+
'sample',
277+
'samples',
278+
1
279+
)
280+
).toBeNull();
281+
expect(
282+
getOperationNotPermittedMessage(new OperationConfirmationData({ notPermitted: [] }), 'sample', 'samples', 1)
283+
).toBeNull();
275284
});
276285

277286
test('with notPermitted', () => {
278-
expect(getOperationNotPermittedMessage(new OperationConfirmationData({ notPermitted: [1] }))).toBe(
279-
'The selection includes 1 sample that you do not have permission to edit. Updates will only be made to the samples you have edit permission for.'
280-
);
281-
expect(getOperationNotPermittedMessage(new OperationConfirmationData({ notPermitted: [1, 2] }))).toBe(
282-
'The selection includes 2 samples that you do not have permission to edit. Updates will only be made to the samples you have edit permission for.'
283-
);
287+
expect(
288+
getOperationNotPermittedMessage(
289+
new OperationConfirmationData({ notPermitted: [1] }),
290+
'sample',
291+
'samples',
292+
1
293+
)
294+
).toBe('You do not have permission to edit the selected sample.');
295+
expect(
296+
getOperationNotPermittedMessage(
297+
new OperationConfirmationData({ notPermitted: [1, 2] }),
298+
'sample',
299+
'samples',
300+
2
301+
)
302+
).toBe('You do not have permission to edit any of the selected samples.');
284303
});
285304
});
286305

packages/components/src/internal/components/samples/utils.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ export function getOperationNotAllowedMessage(
223223
*/
224224
export function getOperationNotPermittedMessage(
225225
statusData: OperationConfirmationData,
226-
nounSingular = 'sample',
227-
nounPlural = 'samples',
226+
nounSingular: string,
227+
nounPlural: string,
228228
totalCount: number
229229
): string {
230230
if (!statusData || statusData.notPermitted.length === 0) return null;

0 commit comments

Comments
 (0)