Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
nagdahimanshu committed Sep 18, 2023
1 parent 97ac524 commit 692a947
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/unit/utils/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,26 @@
* Removal or modification of this copyright notice is prohibited.
*/
import * as fs from 'fs-extra';
import { resolve } from 'path';
import { resolve, join } from 'path';
import { ApplicationConfig } from 'lisk-framework';
import { configV3, configV4 } from '../fixtures/config';
import {
migrateUserConfig,
validateConfig,
writeConfig,
resolveConfigPathByNetworkID,
createBackup,
} from '../../../src/utils/config';
import { ApplicationConfigV3 } from '../../../src/types';

describe('Migrate user configuration', () => {
const migratedConfigFilePath = `${process.cwd()}/test/config`;
const backupPath = join(__dirname, '../../..', 'backup');

afterAll(() => fs.removeSync(migratedConfigFilePath));
afterAll(() => {
fs.removeSync(migratedConfigFilePath);
fs.removeSync(backupPath);
});

it('should migrate user configuration', async () => {
const snapshotHeight = 10815;
Expand Down Expand Up @@ -64,3 +69,11 @@ describe('Test resolveConfigPathByNetworkID method', () => {
await expect(resolveConfigPathByNetworkID('invalid')).rejects.toThrow();
});
});

describe('Test createBackup method', () => {
it('should create backup', async () => {
const backupPath = join(__dirname, '../../..', 'backup');
await createBackup((configV3 as unknown) as ApplicationConfigV3);
expect(fs.existsSync(backupPath)).toBe(true);
});
});

0 comments on commit 692a947

Please sign in to comment.