-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(state): use state for check response step definition
- Loading branch information
matthieu.comby
authored and
Raphaël Benitte
committed
Jun 30, 2017
1 parent
df3ffee
commit a3b734b
Showing
2 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict' | ||
|
||
const state = require('../src/extensions/state/state') | ||
|
||
test('should return null value', () => { | ||
expect(state.populate('((null))')).toBe('((null))') | ||
}) | ||
|
||
test('should return undefined value', () => { | ||
expect(state.populate('((undefined))')).toBe('((undefined))') | ||
}) | ||
|
||
test('should populate value with state data', () => { | ||
state.clear() | ||
state.set('key1', '1') | ||
expect(state.populate('{{key1}}')).toBe('1') | ||
expect(state.populate('{{key1}}((number))')).toBe('1((number))') | ||
}) | ||
|
||
test('should returned complete object populated with the state data', () => { | ||
state.clear() | ||
state.set('key1', 'value1') | ||
state.set('key2', '2') | ||
|
||
const object = { | ||
field1: '{{key1}}', | ||
object2: { | ||
field1: '1((number))', | ||
field2: '{{key2}}((number))' | ||
} | ||
} | ||
|
||
const expectedObject = { | ||
field1: 'value1', | ||
object2: { | ||
field1: '1((number))', | ||
field2: '2((number))' | ||
} | ||
} | ||
|
||
expect(state.populateObject(object)).toEqual(expectedObject) | ||
}) |