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

fix: add a unit test for reset state #570

Merged
merged 1 commit into from
Feb 8, 2019
Merged
Changes from all commits
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
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();
}));
});