NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { SchwabDfgMfeContextContract } from '../../../../dfg-mfe-contracts/src/lib/schwab-dfg-mfe-context.contract';
import { SchwabDfgStoreService } from '../shared/core/store-service/schwab-dfg-store.service';
import { SchwabDfgAnalyticsService } from '../shared/services/analytics-service/schwab-dfg-analytics.service';
import { FakeContextContract } from '../shared/services/fake-context-contract';
import { SchwabDfgGatewayService } from '../shared/services/gateway-service/schwab-dfg-gateway.service';
import { SchwabDfgDashboardComponentmodelService } from './schwab-dfg-dashboard.component-model.service';
import { of } from 'rxjs';
import { SchwabDfgConstants } from '../shared/schwab-dfg-constants';
import { SchwabDfgOnboarding } from '../shared/models/schwab-dfg-onboarding.model';
import { SchwabDfgDashboardResponseModel } from '../shared/models/schwab-dfg-dashboard-response.model';
import { SchwabDfgMyRetirementModel } from 'projects/schwab/dfg-mfe-contracts/src/lib/model/schwab-dfg-my-reitrement-model';

describe('SchwabDfgDashboardComponentmodelService', () => {
let service: SchwabDfgDashboardComponentmodelService;
let gatewayService: SchwabDfgGatewayService;
let httpMock: HttpTestingController;

const mockDashboardResponse: SchwabDfgDashboardResponseModel = {
cards: [],
dashboardData: [],
images: [{ id: 'imageArrow', filePath: 'path/to/arrow' }, { id: 'dashboardbackground', filePath: 'path/to/background' }],
textFields: [
{ id: 'heading', displayValue: 'Heading' },
{ id: 'subHeading', displayValue: 'Subheading' },
{ id: 'speakWithFinancialCoach', displayValue: 'Speak with a financial coach' },
{ id: 'getComprehensiveFinancialPlan', displayValue: 'Get a comprehensive financial plan' },
{ id: 'updateYourInformation', displayValue: 'Update your information' }
],
buttons: [{ id: 'personalizeButton', displayValue: 'Personalize' }, { id: 'updateButton', displayValue: 'Update' }],
modals: [{ id: 'updateModal' }, { id: 'coachingModal' }],
isEnabled: false
};

const mockRetirementProgressData: SchwabDfgMyRetirementModel = {
isRetirementProgressEnabled: true,
isAdviceAllowed: true,
isIncreaseContributionAllowed: true,
mrpIncomeReplacement: 5,
mrpUpdatedDate: new Date(),
};

const mockOnboardingData: SchwabDfgOnboarding = {
maritalStatus: 'Single',
numberOfDependents: 0,
householdIncome: 50000,
financialWellness: 'Good',
};

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [
SchwabDfgDashboardComponentmodelService,
SchwabDfgGatewayService,
SchwabDfgStoreService,
SchwabDfgAnalyticsService,
{
provide: SchwabDfgMfeContextContract,
useValue: new FakeContextContract(),
}
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
});

service = TestBed.inject(SchwabDfgDashboardComponentmodelService);
gatewayService = TestBed.inject(SchwabDfgGatewayService);
httpMock = TestBed.inject(HttpTestingController);
});

afterEach(() => {
httpMock.verify();
});

it('should be created', () => {
expect(service).toBeTruthy();
});

it('should execute service and set access settings in configDataRequest', () => {
spyOn(gatewayService, 'executeService').and.returnValue(of({ body: mockDashboardResponse }));
spyOn(service as any, 'setAccessSettings').and.callThrough();
spyOn(service as any, 'ModellingDashBoardData').and.callThrough();

(service as any).configDataRequest(mockRetirementProgressData).subscribe((response) => {
expect(response).toBeDefined();
expect(service['setAccessSettings']).toHaveBeenCalled();
expect(service['ModellingDashBoardData']).toHaveBeenCalledWith(mockDashboardResponse, mockRetirementProgressData);
});

expect(gatewayService.executeService).toHaveBeenCalledWith(
'dfgOnboardingBff',
'GET',
'',
'/dashboard',
{ 'no-cache': '1', 'Schwab-Retirement-Progress-Supression': 'true' }
);
});

it('should create onboarding model and return ModellingOnboardingData', () => {
spyOn(gatewayService, 'executeService').and.returnValue(of({ body: mockOnboardingData }));
spyOn(service as any, 'ModellingOnboardingData').and.callThrough();

service.createOnboardingModel().subscribe((response) => {
expect(response).toEqual(mockOnboardingData);
expect(service['ModellingOnboardingData']).toHaveBeenCalledWith(mockOnboardingData);
});

expect(gatewayService.executeService).toHaveBeenCalledWith(
'dfgOnboardingBff',
'GET',
'',
'',
{ 'no-cache': '1' }
);
});

it('should return default onboarding data if input is undefined', () => {
const result = service['ModellingOnboardingData'](undefined);
expect(result.maritalStatus).toBe('');
expect(result.numberOfDependents).toBeNull();
expect(result.householdIncome).toBeNull();
expect(result.financialWellness).toBe('');
});

it('should return the same onboarding data if input is defined', () => {
const result = service['ModellingOnboardingData'](mockOnboardingData);
expect(result).toEqual(mockOnboardingData);
});

it('should set access settings correctly', () => {
const mockData = { isEnabled: true } as SchwabDfgDashboardResponseModel;
service['setAccessSettings'](mockData);
expect(service['context'].isFullAccess.value).toBe(true);
});

it('should model dashboard data correctly', () => {
const mockData = { ...mockDashboardResponse, cards: [], textFields: [], images: [], modals: [] } as SchwabDfgDashboardResponseModel;

const result = service['ModellingDashBoardData'](mockData, mockRetirementProgressData);
expect(result).toBeDefined();
expect(result.dashboardCardData.length).toBe(0);
});

it('should handle retirement progress suppression in ModellingDashBoardData', () => {
const mockData = { ...mockDashboardResponse, cards: [{ title: 'Retirement' }], textFields: [], images: [], modals: [] } as SchwabDfgDashboardResponseModel;
const result = service['ModellingDashBoardData'](mockData, mockRetirementProgressData);

const retirementCard = result.dashboardCardData.find(card => card.dashboard.moduleCode === SchwabDfgConstants.RetirementModuleCode.toUpperCase());
expect(retirementCard.dashboard.isProgressSuppressionEnabled).toBe(true);
expect(retirementCard.dashboard.goalProgressPercentage).toBe(mockRetirementProgressData.mrpIncomeReplacement);
expect(retirementCard.dashboard.currentSavingsAsOfDate).toBe(mockRetirementProgressData.mrpUpdatedDate);
});
});
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.