Skip to content

Commit

Permalink
test: mock process env
Browse files Browse the repository at this point in the history
  • Loading branch information
lesyk-lesyk committed May 14, 2024
1 parent b3fcb50 commit 131f9d4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"collectCoverageFrom": ["./src/**"],
"coverageThreshold": {
"global": {
"branches": 56,
"branches": 55,
"functions": 90,
"lines": 80,
"statements": 80
Expand Down
17 changes: 15 additions & 2 deletions src/__tests__/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,22 @@ jest.mock('@actions/github', () => ({
}));

describe('helpers', () => {
const OLD_ENV = process.env;

beforeEach(() => {
jest.resetModules();
jest.clearAllMocks();

process.env = {
...OLD_ENV,
GITHUB_WORKSPACE: '/home/runner/work/reunite-push-action/'
};
getInputMock = jest.spyOn(core, 'getInput').mockImplementation();
});

afterAll(() => {
process.env = OLD_ENV; // Restore old environment
});

describe('parseInputData', () => {
it('should return parsed input data', () => {
getInputMock.mockImplementation(
Expand All @@ -73,7 +83,10 @@ describe('helpers', () => {
redoclyOrgSlug: 'test-org-slug',
redoclyProjectSlug: 'test-project-slug',
redoclyDomain: 'redocly-domain.com',
files: ['testFolder', 'testOpenApiFile.yaml'],
files: [
'/home/runner/work/reunite-push-action/testFolder',
'/home/runner/work/reunite-push-action/testOpenApiFile.yaml'
],
mountPath: 'test/mount/path',
maxExecutionTime: 100,
redoclyConfigPath: 'test/redocly/config/path'
Expand Down

0 comments on commit 131f9d4

Please sign in to comment.