Files
inji-wallet/machines/backupAndRestore/restore/restoreModel.test.ts
Kaushik Gupta 33c6caa08a INJIMOB-3246 Code coverage for Inji-Wallet repo increase above 5% (#2108)
* INJIMOB-3246 Code coverage for Inji-Wallet repo increase above 5%

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

* INJIMOB-3246: added snapshot tests and coverage increased to +4%

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

* removed duplicated lines

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

* Added updateCredentialInformation tests

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

* added code rabbit changes

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

* removed platform-specific tests without mocking

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

* standardize mocks in VcItemContainerProfileImage tests

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

---------

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>
2025-11-07 11:10:37 +05:30

115 lines
3.6 KiB
TypeScript

import {restoreModel} from './restoreModel';
describe('restoreModel', () => {
describe('Model structure', () => {
it('should be defined', () => {
expect(restoreModel).toBeDefined();
});
it('should have initialContext', () => {
expect(restoreModel.initialContext).toBeDefined();
});
it('should have events', () => {
expect(restoreModel.events).toBeDefined();
});
});
describe('Initial Context', () => {
const initialContext = restoreModel.initialContext;
it('should have serviceRefs as empty object', () => {
expect(initialContext.serviceRefs).toEqual({});
expect(typeof initialContext.serviceRefs).toBe('object');
});
it('should have fileName as empty string', () => {
expect(initialContext.fileName).toBe('');
expect(typeof initialContext.fileName).toBe('string');
});
it('should have dataFromBackupFile as empty object', () => {
expect(initialContext.dataFromBackupFile).toEqual({});
expect(typeof initialContext.dataFromBackupFile).toBe('object');
});
it('should have errorReason as empty string', () => {
expect(initialContext.errorReason).toBe('');
expect(typeof initialContext.errorReason).toBe('string');
});
it('should have showRestoreInProgress as false', () => {
expect(initialContext.showRestoreInProgress).toBe(false);
expect(typeof initialContext.showRestoreInProgress).toBe('boolean');
});
it('should have all 5 required properties', () => {
const properties = Object.keys(initialContext);
expect(properties).toHaveLength(5);
});
});
describe('String properties', () => {
const context = restoreModel.initialContext;
it('all empty string properties should be empty', () => {
const emptyStrings = [context.fileName, context.errorReason];
emptyStrings.forEach(str => {
expect(str).toBe('');
expect(typeof str).toBe('string');
});
});
});
describe('Object properties', () => {
const context = restoreModel.initialContext;
it('all empty object properties should be empty objects', () => {
const emptyObjects = [context.serviceRefs, context.dataFromBackupFile];
emptyObjects.forEach(obj => {
expect(typeof obj).toBe('object');
expect(Object.keys(obj)).toHaveLength(0);
});
});
});
describe('Boolean properties', () => {
const context = restoreModel.initialContext;
it('showRestoreInProgress should be false', () => {
expect(context.showRestoreInProgress).toBe(false);
expect(typeof context.showRestoreInProgress).toBe('boolean');
});
it('should have correct initial values for boolean properties', () => {
expect(context.showRestoreInProgress).toBe(false);
});
});
describe('Model events', () => {
it('should have events object', () => {
expect(restoreModel.events).toBeDefined();
expect(typeof restoreModel.events).toBe('object');
});
it('should have event creators', () => {
const eventKeys = Object.keys(restoreModel.events);
expect(eventKeys.length).toBeGreaterThan(0);
});
});
describe('Property types validation', () => {
const context = restoreModel.initialContext;
it('should have correct types for all properties', () => {
expect(typeof context.serviceRefs).toBe('object');
expect(typeof context.fileName).toBe('string');
expect(typeof context.dataFromBackupFile).toBe('object');
expect(typeof context.errorReason).toBe('string');
expect(typeof context.showRestoreInProgress).toBe('boolean');
});
});
});