From 16fae7ee7853a55a12364ce20d43d97fd0b97ddc Mon Sep 17 00:00:00 2001 From: Jens Astrup Date: Tue, 4 Jun 2024 03:35:06 -0400 Subject: [PATCH] Lint story-custom-field.test.ts (#278) --- .../custom-fields/story-custom-field.test.ts | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/tests/stories/custom-fields/story-custom-field.test.ts b/tests/stories/custom-fields/story-custom-field.test.ts index 2bd1bbd..03c4853 100644 --- a/tests/stories/custom-fields/story-custom-field.test.ts +++ b/tests/stories/custom-fields/story-custom-field.test.ts @@ -5,36 +5,35 @@ import StoryCustomFieldInterface from '@sx/stories/custom-fields/contracts/story import StoryCustomField from '@sx/stories/custom-fields/story-custom-field' -jest.mock('../../../src/utils/headers', () => ({ - getHeaders: jest.fn().mockReturnValue({Authorization: 'Bearer token'}) +jest.mock('@sx/utils/headers', () => ({ + getHeaders: jest.fn().mockReturnValue({ Authorization: 'Bearer token' }) })) describe('Story Custom Field', () => { it('should instantiate a new custom field', () => { - const customField = new StoryCustomField({fieldId: '1'} as StoryCustomFieldInterface) + const customField = new StoryCustomField({ fieldId: '1' } as StoryCustomFieldInterface) expect(customField).toBeInstanceOf(StoryCustomField) }) it('should return saved custom field', async () => { - const storyCustomField = new StoryCustomField({fieldId: '1'} as StoryCustomFieldInterface) - const customField: CustomField = new CustomField({id: '1'} as CustomFieldInterface) + const storyCustomField = new StoryCustomField({ fieldId: '1' } as StoryCustomFieldInterface) + const customField: CustomField = new CustomField({ id: '1' } as CustomFieldInterface) const customFieldGet = jest.spyOn(CustomFieldsService.prototype, 'get').mockResolvedValue(customField) const savedCustomField: CustomField = await storyCustomField.field expect(savedCustomField).toBeInstanceOf(CustomField) await expect(storyCustomField.field).resolves.toBeInstanceOf(CustomField) expect(customFieldGet).toHaveBeenCalledTimes(1) - }) it('should return a field', async () => { jest.spyOn(CustomFieldsService.prototype, 'get').mockResolvedValue(new CustomField({ id: '1', - values: [{fieldId: '1', value: 'value'} as unknown as CustomFieldInterface] + values: [{ fieldId: '1', value: 'value' } as unknown as CustomFieldInterface] } as unknown as CustomFieldInterface)) - const customStoryField: StoryCustomField = new StoryCustomField({fieldId: '1'} as StoryCustomFieldInterface) + const customStoryField: StoryCustomField = new StoryCustomField({ fieldId: '1' } as StoryCustomFieldInterface) const customField: CustomField = await customStoryField.field - expect(customField.values).toEqual([{fieldId: '1', value: 'value'}]) + expect(customField.values).toEqual([{ fieldId: '1', value: 'value' }]) expect(customField).toBeInstanceOf(CustomField) }) @@ -45,9 +44,9 @@ describe('Story Custom Field', () => { canonicalName: 'fieldName', createdAt: new Date(), description: 'description', - values: [{fieldId: '1', value: 'value'}] + values: [{ fieldId: '1', value: 'value' }] } as unknown as CustomFieldInterface)) - const customStoryField: StoryCustomField = new StoryCustomField({fieldId: '1'} as StoryCustomFieldInterface) + const customStoryField: StoryCustomField = new StoryCustomField({ fieldId: '1' } as StoryCustomFieldInterface) const customFieldName: string = await customStoryField.name expect(customFieldName).toEqual('field') })