Skip to content

Commit

Permalink
Mock spinner to avoid test fail by unclosed handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
Rindrics committed Jun 18, 2024
1 parent bd793ac commit 703dcb5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import { AWSConfig } from './config';
import { mockClient } from 'aws-sdk-client-mock';
import AWSMock from 'aws-sdk-mock';

jest.mock('./logger', () => ({
...jest.requireActual('./logger'),
showSpinner: jest.fn(),
}));

describe('getAccountAlias', () => {
const organizationsMock = mockClient(OrganizationsClient);

Expand Down
5 changes: 5 additions & 0 deletions src/cost.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ const costDataLength = 65;
const fixedToday = '2024-05-11'; // cost of 'this month' will be sum of 10 days from May 1 to May 10 ('today' is omitted because its cost is incomplete)
const fixedFirstDay = dayjs(fixedToday).subtract(costDataLength, 'day');

jest.mock('./logger', () => ({
...jest.requireActual('./logger'),
showSpinner: jest.fn(),
}));

describe('Cost Functions', () => {
beforeAll(() => {
AWSMock.setSDKInstance(AWS);
Expand Down
5 changes: 5 additions & 0 deletions src/printers/slack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const awsConfig: AWSConfig = {
region: 'us-east-1',
};

jest.mock('../logger', () => ({
...jest.requireActual('../logger'),
showSpinner: jest.fn(),
}));

const mockedCostByService = generateMockedCostByService(
fixedToday,
costDataLength,
Expand Down

0 comments on commit 703dcb5

Please sign in to comment.