Skip to content

Commit

Permalink
Update unit test to be more meaningful/robust
Browse files Browse the repository at this point in the history
  • Loading branch information
cshfang committed Apr 30, 2024
1 parent fd859f9 commit 2f3d65d
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,23 @@ describe('Pinpoint Provider Util: createEndpointId', () => {
// assert mocks
const mockAmplifyUuid = amplifyUuid as jest.Mock;

afterEach(() => {
mockAmplifyUuid.mockReset();
});

it('returns a new endpoint id for a category', () => {
mockAmplifyUuid.mockReturnValue(uuid);

expect(createEndpointId(appId, category)).toBe(uuid);
expect(mockAmplifyUuid).toHaveBeenCalled();
});

it('returns the same endpoint id for a category', () => {
const newUuid = `new-${uuid}`;
mockAmplifyUuid.mockReturnValue(newUuid);

expect(createEndpointId(appId, category)).toBe(uuid);
expect(mockAmplifyUuid).not.toHaveBeenCalled();
});

it('returns a new endpoint id for a different category', () => {
Expand All @@ -33,6 +39,7 @@ describe('Pinpoint Provider Util: createEndpointId', () => {
mockAmplifyUuid.mockReturnValue(newUuid);

expect(createEndpointId(appId, newCategory)).toBe(newUuid);
expect(mockAmplifyUuid).toHaveBeenCalled();
});

it('clears a created endpoint id for a category', () => {
Expand Down

0 comments on commit 2f3d65d

Please sign in to comment.