Skip to content

Commit

Permalink
tests: Mock cliConfig.ts on preload
Browse files Browse the repository at this point in the history
  • Loading branch information
angelmadames committed Mar 28, 2024
1 parent d199072 commit c4fb74f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
31 changes: 31 additions & 0 deletions test/setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { afterEach, beforeAll, beforeEach, jest, mock, spyOn } from 'bun:test';
import cliConfig from '../src/config/cli';
import { projectConfig } from '../src/config/project';

beforeAll(() => {
mock.module('node:fs', () => ({
Expand All @@ -15,6 +17,35 @@ beforeAll(() => {
},
}));

mock.module('../src/config/cli', () => ({
currentProject: () => 'test-project',
default: {
currentProject: 'test-project',
currentProjectFile: 'test-project-fioe',
root: '/path/to/root',
file: '/path/to/file',
},
}));

mock.module('../src/config/project', () => ({
projectConfig: {
compose: {
project_name: 'my-project',
},
paths: {
env_file: '/path/to/env_file',
repos_root: '/path/to/repos_root',
repos: {},
},
repositories: ['repo1', 'repo2'],
dockerfile: '',
git: {
org_url: '',
default_ref: '',
},
},
}));

mock.module('@inquirer/prompts', () => ({
confirm: mock(),
}));
Expand Down
4 changes: 2 additions & 2 deletions test/utils/compose.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const testConfigJson: DEMSProjectConfig = {

describe('Utils: compose', () => {
describe('composeExecParams', () => {
test.skip('should return an array of compose parameters', () => {
test('should return an array of compose parameters', () => {
(fs.existsSync as jest.Mock).mockReturnValue(true);
(fs.lstatSync as jest.Mock).mockReturnValue({ isFile: () => true });

Expand All @@ -42,7 +42,7 @@ describe('Utils: compose', () => {

describe('Utils: compose', () => {
describe('composeFiles', () => {
test.skip('should return an array of compose files with --file flag', () => {
test('should return an array of compose files with --file flag', () => {
(fs.existsSync as jest.Mock).mockReturnValue(true);
(fs.lstatSync as jest.Mock).mockReturnValue({ isFile: () => true });
(fs.readdirSync as jest.Mock).mockReturnValue([
Expand Down

0 comments on commit c4fb74f

Please sign in to comment.