Skip to content
This repository has been archived by the owner on Jul 23, 2019. It is now read-only.

Commit

Permalink
fix: add a unit test for reset state (#570)
Browse files Browse the repository at this point in the history
  • Loading branch information
vikram-raj authored and edewit committed Feb 8, 2019
1 parent 9e3efda commit 6c9d981
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions projects/ngx-launcher/src/lib/model/projectile.model.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { HttpParams } from '@angular/common/http';
import { async } from '@angular/core/testing';
import { GitHubDetails } from './github-details.model';
import { Mission } from './mission.model';
import { Projectile, StepState } from './projectile.model';
Expand Down Expand Up @@ -62,4 +63,20 @@ describe('State saving and restoring', () => {
const restoredMission = projectile.restore(testStateId, missions);
expect(restoredMission.state.mission.description).toEqual(description);
});

it('should set the state of the component', async(() => {
const projectile = new TestableProjectile<any>();
projectile.setState('newState', new StepState<any>({ 'param1': 'value1' }, [{ name: 'p1', value: 'param1' }]));
const newState = { p1: 'value1' };
const _newState = projectile.getSavedState('newState');
expect(_newState).toEqual(newState);
}));

it('should reset the state of the component', async(() => {
const projectile = new TestableProjectile<any>();
projectile.setState('newState', new StepState<any>({ 'param1': 'value1' }, [{ name: 'p1', value: 'param1' }]));
projectile.resetState();
const currentState = projectile.getSavedState('newState');
expect(currentState).toBeNull();
}));
});

0 comments on commit 6c9d981

Please sign in to comment.