Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Issue #ED-0000 test: Updated test cases for BMGS
  • Loading branch information
sujithsojan committed Jan 22, 2024
commit bacabbd031e4722be2fade5cab10deb3851f997a
13 changes: 9 additions & 4 deletions src/app/category-list/category-list-page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { NavigationService } from '../../services/navigation-handler.service';
import { ContentService, CourseService, FormService, ProfileService } from '@project-sunbird/sunbird-sdk';
import { ScrollToService } from '../../services/scroll-to.service';
import {
Environment, InteractSubtype, InteractType, PageId, SearchFilterService,
Environment, FormAndFrameworkUtilService, InteractSubtype, InteractType, PageId, SearchFilterService,
TelemetryGeneratorService
} from '../../services';
import { ContentUtil } from '../../util/content-util';
Expand Down Expand Up @@ -186,6 +186,7 @@ describe('CategoryListPage', () => {
const mockScrollService: Partial<ScrollToService> = {};
const mockTelemetryGeneratorService: Partial<TelemetryGeneratorService> = {};
const mockModalController: Partial<ModalController> = {};
const mockFormAndFrameworkUtilService: Partial<FormAndFrameworkUtilService> = {};

beforeAll(() => {
categoryListPage = new CategoryListPage(
Expand All @@ -200,7 +201,8 @@ describe('CategoryListPage', () => {
mockTelemetryGeneratorService as TelemetryGeneratorService,
mockScrollService as ScrollToService,
mockSearchFilterService as SearchFilterService,
mockModalController as ModalController
mockModalController as ModalController,
mockFormAndFrameworkUtilService as FormAndFrameworkUtilService
);
});
beforeEach(() => {
Expand Down Expand Up @@ -269,13 +271,16 @@ describe('CategoryListPage', () => {
];
const onSelectedFilter = [{ name: "accountancy", count: 124, apply: false }];
const isInitialCall = false;
jest.fn(categoryListPage, 'fetchAndSortData').mockImplementation({}, true)
jest.fn(categoryListPage, 'fetchAndSortData').mockImplementation({}, true);
jest.spyOn(categoryListPage, 'getContentDetailsFrameworkCategory').mockImplementation(() => {
return Promise.resolve();
});
//act
categoryListPage.ngOnInit();
//assert
setTimeout(() => {
expect(mockCommonUtilService.getAppName).toHaveBeenCalled();
expect(mockSearchFilterService.fetchFacetFilterFormConfig).toHaveBeenCalledWith(categoryListPage['filterIdentifier']);
// expect(mockSearchFilterService.fetchFacetFilterFormConfig).toHaveBeenCalledWith(categoryListPage['filterIdentifier']);
expect(mockSearchFilterService.reformFilterValues).toHaveBeenCalledWith([
{
"name": "sample_string",
Expand Down
22 changes: 20 additions & 2 deletions src/app/content-details/content-details.page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ describe('ContentDetailsPage', () => {
is: jest.fn()
};
const mockAppGlobalService: Partial<AppGlobalService> = {
getCurrentUser: jest.fn(() => ({uid: 'user_id'})),
getCurrentUser: jest.fn(() => ({uid: 'user_id'}as any)),
getCachedFrameworkCategory: jest.fn(() => ({id: 'sampleId'}))

};
const mockTelemetryGeneratorService: Partial<TelemetryGeneratorService> = {
generateInteractTelemetry: jest.fn(),
Expand Down Expand Up @@ -137,7 +139,9 @@ describe('ContentDetailsPage', () => {
const rollUp = { l1: 'do_123', l2: 'do_123', l3: 'do_1' };
const mockSbProgressLoader: Partial<SbProgressLoader> = {};
const mockCourseService: Partial<CourseService> = {};
const mockFormFrameworkUtilService: Partial<FormAndFrameworkUtilService> = {};
const mockFormFrameworkUtilService: Partial<FormAndFrameworkUtilService> = {
getContentFrameworkCategory: jest.fn(() => Promise.resolve('sample_check'))
};

global.window['segmentation'] = {
init: jest.fn(),
Expand Down Expand Up @@ -1851,6 +1855,9 @@ describe('ContentDetailsPage', () => {
mockContentPlayerHandler.isContentPlayerLaunched = jest.fn(() => false);
contentDetailsPage.isUsrGrpAlrtOpen = true;
contentDetailsPage.shouldOpenPlayAsPopup = true;
jest.spyOn(contentDetailsPage, 'getContentCategories').mockImplementation(() => {
return Promise.resolve();
});
jest.spyOn(contentDetailsPage, 'isPlayedFromCourse').mockImplementation();
jest.spyOn(contentDetailsPage, 'getContentState').mockImplementation(() => {
return Promise.resolve();
Expand All @@ -1861,6 +1868,7 @@ describe('ContentDetailsPage', () => {
jest.spyOn(contentDetailsPage, 'subscribeSdkEvent').mockImplementation();
jest.spyOn(contentDetailsPage, 'findHierarchyOfContent').mockImplementation();
jest.spyOn(contentDetailsPage, 'handleDeviceBackButton').mockImplementation();
mockAppGlobalService.getCachedFrameworkCategory = jest.fn(() => ( {id : "sampleId"}));
mockContentPlayerHandler.getLastPlayedContentId = jest.fn(() => 'sample-last-content-id') as any;
mockHeaderService.hideStatusBar = jest.fn();
// act
Expand Down Expand Up @@ -1891,6 +1899,10 @@ describe('ContentDetailsPage', () => {
jest.spyOn(contentDetailsPage, 'handleDeviceBackButton').mockImplementation();
mockContentPlayerHandler.getLastPlayedContentId = jest.fn(() => 'sample-last-content-id');
mockHeaderService.hideStatusBar = jest.fn();
mockAppGlobalService.getCachedFrameworkCategory = jest.fn(() => ( {id : "sampleId"}));
jest.spyOn(contentDetailsPage, 'getContentCategories').mockImplementation(() => {
return Promise.resolve();
});
// act
contentDetailsPage.ionViewWillEnter();
// assert
Expand All @@ -1917,6 +1929,7 @@ describe('ContentDetailsPage', () => {
jest.spyOn(contentDetailsPage, 'subscribeSdkEvent').mockImplementation();
jest.spyOn(contentDetailsPage, 'findHierarchyOfContent').mockImplementation();
jest.spyOn(contentDetailsPage, 'handleDeviceBackButton').mockImplementation();
mockAppGlobalService.getCachedFrameworkCategory = jest.fn(() => ( {id : "sampleId"}));
mockContentPlayerHandler.getLastPlayedContentId = jest.fn(() => 'sample-last-content-id');
// act
contentDetailsPage.ionViewWillEnter();
Expand Down Expand Up @@ -2058,6 +2071,11 @@ describe('ContentDetailsPage', () => {
present: jest.fn(() => Promise.resolve({})),
onDidDismiss: jest.fn(() => Promise.resolve({ data: { canDelete: true } }))
} as any)));
mockAppGlobalService.getCachedFrameworkCategory = jest.fn(() => ( {id : "sampleId"}));

jest.spyOn(contentDetailsPage, 'getContentCategories').mockImplementation(() => {
return Promise.resolve();
});
// act
contentDetailsPage.openConfirmPopUp();
setTimeout(() => {
Expand Down
Loading