Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix import paths of dayjs plugins #23

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ jobs:
node-version-file: '.node-version'
cache: 'pnpm'

- name: Install dependencies
run: make install
- name: Install dependencies & build application
run: make

- name: Lint & format
run: make lint

- name: Run tests
run: make test

- name: Confirm no error
run: make version
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ lint:

format:
pnpm format

version:
pnpm exec node $(BUILD_DIR)/index.js --version
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
4 changes: 2 additions & 2 deletions src/cost.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import AWS from 'aws-sdk';
import dayjs from 'dayjs';
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter.js';
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore.js';
dayjs.extend(isSameOrAfter);
dayjs.extend(isSameOrBefore);
import { AWSConfig } from './config';
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