Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {
- async,
- ComponentFixture,
- fakeAsync,
- TestBed
- } from '@angular/core/testing';
- import { Subject } from 'rxjs';
- import { TestUtils } from '../../../test';
- import { AddressBookProvider } from '../../../providers/address-book/address-book';
- import { ConfigProvider } from './../../../providers/config/config';
- import { FeePolicyPage } from './fee-policy';
- describe('FeePolicyPage', () => {
- let fixture: ComponentFixture<FeePolicyPage>;
- let instance: any;
- let testBed: typeof TestBed;
- beforeEach(
- async(() =>
- TestUtils.configurePageTestingModule([FeePolicyPage]).then(testEnv => {
- fixture = testEnv.fixture;
- instance = testEnv.instance;
- testBed = testEnv.testBed;
- instance.showCard = {
- setShowRateCard: () => { }
- };
- fixture.detectChanges();
- })
- )
- );
- afterEach(() => {
- fixture.destroy();
- });
- describe('Lifecycle Hooks', () => {
- describe('ionViewDidEnter', () => {
- beforeEach(function () {
- spyOn(instance.logger, 'error');
- spyOn(instance, 'updateCurrentValues');
- });
- fit('should set new fee level and update current values', () => {
- const pMock = Promise.resolve("data");
- spyOn(instance.feeProvider, 'getFeeLevels').and.returnValue(pMock);
- instance.ionViewDidEnter();
- expect(instance.updateCurrentValues).toHaveBeenCalled();
- });
- // it('should log and set new error if getFeeLevels fails', () => {
- // spyOn(instance.feeProvider, 'getFeeLevels').and.throwError("bad error");
- // instance.ionViewDidEnter();
- // expect(instance.logger.error).toHaveBeenCalled();
- // // expect(instance.error).toEqual("bad error");
- // });
- });
- });
- describe('Methods', () => {
- describe('#save', () => {
- beforeEach(function () {
- spyOn(instance.logger, 'debug');
- spyOn(instance, 'updateCurrentValues');
- spyOn(instance, 'setFee');
- spyOn(instance.feeProvider, 'getCurrentFeeLevel').and.returnValue('urgent');
- });
- it('should do nothing if current fee level is empty', () => {
- instance.currentFeeLevel = null;
- instance.save();
- expect(instance.logger.debug).not.toHaveBeenCalled();
- expect(instance.updateCurrentValues).not.toHaveBeenCalled();
- expect(instance.setFee).not.toHaveBeenCalled();
- });
- it('should do nothing if current fee level equals existing fee level', () => {
- instance.currentFeeLevel = 'urgent';
- instance.save();
- expect(instance.logger.debug).not.toHaveBeenCalled();
- expect(instance.updateCurrentValues).not.toHaveBeenCalled();
- expect(instance.setFee).not.toHaveBeenCalled();
- });
- it('should log new fee level, update current values, and set new fee level', () => {
- instance.currentFeeLevel = 'normal';
- instance.save();
- expect(instance.logger.debug).toHaveBeenCalled();
- expect(instance.updateCurrentValues).toHaveBeenCalled();
- expect(instance.setFee).toHaveBeenCalled();
- });
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement