File tree Expand file tree Collapse file tree 3 files changed +29
-5
lines changed Expand file tree Collapse file tree 3 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -87,10 +87,15 @@ When(
8787
8888/**
8989 * Save value to memory
90- * @param {string } value
91- * @param {string } key
90+ * @param {string } alias - value to save or alias for previously saved value
91+ * @param {string } key - key to store value
9292 * @example I save 'value' to memory as 'key'
93+ * @example I save '$getRandomUser()' to memory as 'user'
9394 */
94- When ( 'I save {string} to memory as {string}' , function ( value : string , key : string ) {
95- memory . setValue ( key , value ) ;
96- } ) ;
95+ When (
96+ 'I save {string} to memory as {string}' ,
97+ async function ( alias : string , key : string ) {
98+ const value : string = await memory . getValue ( alias ) ;
99+ memory . setValue ( key , value ) ;
100+ }
101+ ) ;
Original file line number Diff line number Diff line change @@ -3,3 +3,11 @@ Feature: Memory
33 Scenario : math expression
44 When I save result of math expression '32 + 1' as 'result'
55 Then I expect '$result' to be equal '33'
6+
7+ Scenario : save result of sync computed to memory
8+ When I save "$getString()" to memory as 'string1'
9+ Then I expect '$string1' to be equal 'I was computed'
10+
11+ Scenario : save result of async computed to memory
12+ When I save "$getStringAsync()" to memory as 'string1'
13+ Then I expect '$string1' to be equal 'I was computed async'
Original file line number Diff line number Diff line change 11export default class Memory {
2+ getString = function ( ) : string {
3+ return 'I was computed' ;
4+ } ;
5+
6+ getStringAsync = function ( ) : Promise < string > {
7+ return new Promise ( ( resolve , reject ) => {
8+ setTimeout ( ( ) => {
9+ resolve ( 'I was computed async' ) ;
10+ } , 50 ) ;
11+ } ) ;
12+ }
213}
You can’t perform that action at this time.
0 commit comments