diff --git a/test/unit/sfErrorTest.ts b/test/unit/sfErrorTest.ts index 3a5f873c7c..87969bd2f7 100644 --- a/test/unit/sfErrorTest.ts +++ b/test/unit/sfErrorTest.ts @@ -72,6 +72,29 @@ describe('SfError', () => { }); }); + describe('generic for data', () => { + class ErrorWithBooleanData extends SfError {} + it('should accept a generic for data and allow a valid set', () => { + const err = new ErrorWithBooleanData('test'); + err.setData(true); + expect(err.data).to.equal(true); + }); + + it('should not allow an invalid set', () => { + const err = new ErrorWithBooleanData('test'); + // @ts-expect-error invalid boolean + err.setData(5); + // @ts-expect-error invalid boolean + err.setData('foo'); + }); + + it('should allow anything on the original unknown', () => { + const err = new SfError('test'); + err.setData(5); + err.setData('foo'); + err.setData({ bar: 6 }); + }); + }); describe('toObject', () => { it('should return the proper JSON object WITH context and data', () => { const message = 'its a trap!';