mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-09 21:48:04 -05:00
* 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>
139 lines
4.5 KiB
TypeScript
139 lines
4.5 KiB
TypeScript
import {backupAndRestoreSetupModel} from './backupAndRestoreSetupModel';
|
|
|
|
describe('backupAndRestoreSetupModel', () => {
|
|
describe('Model structure', () => {
|
|
it('should be defined', () => {
|
|
expect(backupAndRestoreSetupModel).toBeDefined();
|
|
});
|
|
|
|
it('should have initialContext', () => {
|
|
expect(backupAndRestoreSetupModel.initialContext).toBeDefined();
|
|
});
|
|
|
|
it('should have events', () => {
|
|
expect(backupAndRestoreSetupModel.events).toBeDefined();
|
|
});
|
|
});
|
|
|
|
describe('Initial Context', () => {
|
|
const initialContext = backupAndRestoreSetupModel.initialContext;
|
|
|
|
it('should have isLoading as false', () => {
|
|
expect(initialContext.isLoading).toBe(false);
|
|
expect(typeof initialContext.isLoading).toBe('boolean');
|
|
});
|
|
|
|
it('should have profileInfo as undefined', () => {
|
|
expect(initialContext.profileInfo).toBeUndefined();
|
|
});
|
|
|
|
it('should have errorMessage as empty string', () => {
|
|
expect(initialContext.errorMessage).toBe('');
|
|
expect(typeof initialContext.errorMessage).toBe('string');
|
|
});
|
|
|
|
it('should have serviceRefs as empty object', () => {
|
|
expect(initialContext.serviceRefs).toEqual({});
|
|
expect(typeof initialContext.serviceRefs).toBe('object');
|
|
});
|
|
|
|
it('should have shouldTriggerAutoBackup as false', () => {
|
|
expect(initialContext.shouldTriggerAutoBackup).toBe(false);
|
|
expect(typeof initialContext.shouldTriggerAutoBackup).toBe('boolean');
|
|
});
|
|
|
|
it('should have isCloudSignedIn as false', () => {
|
|
expect(initialContext.isCloudSignedIn).toBe(false);
|
|
expect(typeof initialContext.isCloudSignedIn).toBe('boolean');
|
|
});
|
|
|
|
it('should have all 6 required properties', () => {
|
|
const properties = Object.keys(initialContext);
|
|
expect(properties).toHaveLength(6);
|
|
});
|
|
});
|
|
|
|
describe('String properties', () => {
|
|
const context = backupAndRestoreSetupModel.initialContext;
|
|
|
|
it('errorMessage should be empty', () => {
|
|
expect(context.errorMessage).toBe('');
|
|
expect(typeof context.errorMessage).toBe('string');
|
|
});
|
|
});
|
|
|
|
describe('Object properties', () => {
|
|
const context = backupAndRestoreSetupModel.initialContext;
|
|
|
|
it('serviceRefs should be empty object', () => {
|
|
expect(typeof context.serviceRefs).toBe('object');
|
|
expect(Object.keys(context.serviceRefs)).toHaveLength(0);
|
|
});
|
|
});
|
|
|
|
describe('Boolean properties', () => {
|
|
const context = backupAndRestoreSetupModel.initialContext;
|
|
|
|
it('isLoading should be false', () => {
|
|
expect(context.isLoading).toBe(false);
|
|
expect(typeof context.isLoading).toBe('boolean');
|
|
});
|
|
|
|
it('shouldTriggerAutoBackup should be false', () => {
|
|
expect(context.shouldTriggerAutoBackup).toBe(false);
|
|
expect(typeof context.shouldTriggerAutoBackup).toBe('boolean');
|
|
});
|
|
|
|
it('isCloudSignedIn should be false', () => {
|
|
expect(context.isCloudSignedIn).toBe(false);
|
|
expect(typeof context.isCloudSignedIn).toBe('boolean');
|
|
});
|
|
|
|
it('should have correct initial values for boolean properties', () => {
|
|
const falseProps = [
|
|
context.isLoading,
|
|
context.shouldTriggerAutoBackup,
|
|
context.isCloudSignedIn,
|
|
];
|
|
|
|
falseProps.forEach(prop => {
|
|
expect(prop).toBe(false);
|
|
expect(typeof prop).toBe('boolean');
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('Undefined properties', () => {
|
|
const context = backupAndRestoreSetupModel.initialContext;
|
|
|
|
it('profileInfo should be undefined', () => {
|
|
expect(context.profileInfo).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe('Model events', () => {
|
|
it('should have events object', () => {
|
|
expect(backupAndRestoreSetupModel.events).toBeDefined();
|
|
expect(typeof backupAndRestoreSetupModel.events).toBe('object');
|
|
});
|
|
|
|
it('should have event creators', () => {
|
|
const eventKeys = Object.keys(backupAndRestoreSetupModel.events);
|
|
expect(eventKeys.length).toBeGreaterThan(0);
|
|
});
|
|
});
|
|
|
|
describe('Property types validation', () => {
|
|
const context = backupAndRestoreSetupModel.initialContext;
|
|
|
|
it('should have correct types for all properties', () => {
|
|
expect(typeof context.isLoading).toBe('boolean');
|
|
expect(context.profileInfo).toBeUndefined();
|
|
expect(typeof context.errorMessage).toBe('string');
|
|
expect(typeof context.serviceRefs).toBe('object');
|
|
expect(typeof context.shouldTriggerAutoBackup).toBe('boolean');
|
|
expect(typeof context.isCloudSignedIn).toBe('boolean');
|
|
});
|
|
});
|
|
});
|