blob: d11af584c897b3db9ea4d65d5daf590d1deab5c9 [file] [log] [blame]
/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
import { AddressTypesListComponent } from '@pages/admin/address-types/address-types-list/address-types-list.component';
import { AddressType } from '@shared/models';
describe('AddressTypesListComponent', () => {
let component: AddressTypesListComponent;
const sandbox: any = {
setDisplayForm: () => {},
loadAddressType: () => {},
deleteAddressType: () => {},
};
beforeEach(() => {
component = new AddressTypesListComponent(sandbox);
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should initialize gridOptions context', () => {
component.ngOnInit();
expect(component.gridOptions.context.icons.edit).toBeTruthy();
expect(component.gridOptions.context.icons.delete).toBeTruthy();
});
it('should call appropriate functions for edit event', () => {
const spy1: any = spyOn(sandbox, 'setDisplayForm');
const spy2: any = spyOn(sandbox, 'loadAddressType');
component.ngOnInit();
component.gridOptions.context.eventSubject.next({type: "edit", data: new AddressType()});
expect(spy1).toHaveBeenCalled();
expect(spy2).toHaveBeenCalled();
});
it('should call appropriate functions for delete event', () => {
const spy3: any = spyOn(sandbox, 'deleteAddressType');
component.ngOnInit();
component.gridOptions.context.eventSubject.next({type: "delete", data: new AddressType()});
expect(spy3).toHaveBeenCalled();
});
});