From c98b03050feca91407ba0f7747cc2ae701c3cd81 Mon Sep 17 00:00:00 2001 From: LironEr Date: Sat, 1 Jul 2023 11:00:29 +0300 Subject: [PATCH] add success case --- .../src/cli/__tests__/assets/success.json | 4 ++++ .../src/cli/__tests__/configFile.spec.ts | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 packages/bundlemon/src/cli/__tests__/assets/success.json diff --git a/packages/bundlemon/src/cli/__tests__/assets/success.json b/packages/bundlemon/src/cli/__tests__/assets/success.json new file mode 100644 index 0000000..f4aa994 --- /dev/null +++ b/packages/bundlemon/src/cli/__tests__/assets/success.json @@ -0,0 +1,4 @@ +{ + "baseDir": "build", + "verbose": true +} diff --git a/packages/bundlemon/src/cli/__tests__/configFile.spec.ts b/packages/bundlemon/src/cli/__tests__/configFile.spec.ts index 4e67102..364a25b 100644 --- a/packages/bundlemon/src/cli/__tests__/configFile.spec.ts +++ b/packages/bundlemon/src/cli/__tests__/configFile.spec.ts @@ -1,31 +1,42 @@ +import path from 'path'; import { loadConfigFile } from '../configFile'; +const SUCCESS_FILE_CONFIG = { + baseDir: 'build', + verbose: true, +}; describe('load config file', () => { beforeEach(() => { jest.resetAllMocks(); }); + test('success', async () => { + const config = await loadConfigFile(path.join(__dirname, 'assets', 'success.json')); + + expect(config).toEqual(SUCCESS_FILE_CONFIG); + }); + describe('failure', () => { test('empty', async () => { - const config = await loadConfigFile('src/cli/__tests__/assets/empty.json'); + const config = await loadConfigFile(path.join(__dirname, 'assets', 'empty.json')); expect(config).toBeUndefined(); }); test('bad format JSON', async () => { - const config = await loadConfigFile('src/cli/__tests__/assets/bad-format.json'); + const config = await loadConfigFile(path.join(__dirname, 'assets', 'bad-format.json')); expect(config).toBeUndefined(); }); test('bad format YAML', async () => { - const config = await loadConfigFile('src/cli/__tests__/assets/bad-format.yaml'); + const config = await loadConfigFile(path.join(__dirname, 'assets', 'bad-format.yaml')); expect(config).toBeUndefined(); }); test('bad format JS', async () => { - const config = await loadConfigFile('src/cli/__tests__/assets/bad-format.js'); + const config = await loadConfigFile(path.join(__dirname, 'assets', 'bad-format.js')); expect(config).toBeUndefined(); });