From f241ccd761332e5a16344060b3f38e26ef02be4c Mon Sep 17 00:00:00 2001 From: Vikram Raj Date: Fri, 8 Feb 2019 15:34:02 +0530 Subject: [PATCH] fix: add a unit test for reset state --- .../src/lib/model/projectile.model.spec.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/projects/ngx-launcher/src/lib/model/projectile.model.spec.ts b/projects/ngx-launcher/src/lib/model/projectile.model.spec.ts index c808af11..28f0d395 100644 --- a/projects/ngx-launcher/src/lib/model/projectile.model.spec.ts +++ b/projects/ngx-launcher/src/lib/model/projectile.model.spec.ts @@ -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'; @@ -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(); + projectile.setState('newState', new StepState({ '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(); + projectile.setState('newState', new StepState({ 'param1': 'value1' }, [{ name: 'p1', value: 'param1' }])); + projectile.resetState(); + const currentState = projectile.getSavedState('newState'); + expect(currentState).toBeNull(); + })); });