@cuppet/core 1.3.3 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -63,9 +63,35 @@ When(
|
|
|
63
63
|
await dataStorage.generateAndSaveDateWithCustomFormat(format, variable, days);
|
|
64
64
|
}
|
|
65
65
|
);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Generate date with custom format and timezone and store it in a variable
|
|
68
|
+
* @param format - date format
|
|
69
|
+
* @param variable - variable name
|
|
70
|
+
* @param offset - UTC offset in hours (acceptable values are -12, -6, -3, 0, 3, 6, 12, etc.)
|
|
71
|
+
* @returns {Promise<void>}
|
|
72
|
+
*/
|
|
73
|
+
When(
|
|
74
|
+
'I generate date in {string} format for today with UTC offset {int} hours and store it in {string}',
|
|
75
|
+
async function (format, offset, variable) {
|
|
76
|
+
const utcOffset = offset * 60;
|
|
77
|
+
await dataStorage.generateAndSaveDateWithCustomFormatAndTz(format, variable, 0, utcOffset);
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
/**
|
|
81
|
+
* Generate date with custom format and timezone and store it in a variable
|
|
82
|
+
* @param format - date format
|
|
83
|
+
* @param variable - variable name
|
|
84
|
+
* @param days - number of days to add/subtract from the current date
|
|
85
|
+
* @param offset - UTC offset in hours (acceptable values are -12, -6, -3, 0, 3, 6, 12, etc.)
|
|
86
|
+
* @returns {Promise<void>}
|
|
87
|
+
*/
|
|
88
|
+
When(
|
|
89
|
+
'I generate date in {string} format for {string} days from now with UTC offset {int} hours and store it in {string}',
|
|
90
|
+
async function (format, offset, days, variable) {
|
|
91
|
+
const utcOffset = offset * 60;
|
|
92
|
+
await dataStorage.generateAndSaveDateWithCustomFormatAndTz(format, variable, days, utcOffset);
|
|
93
|
+
}
|
|
94
|
+
);
|
|
69
95
|
When('I create json object from {string} file and store it in {string} variable', async function (filePath, variable) {
|
|
70
96
|
const checkedPath = await dataStorage.checkForSavedVariable(filePath);
|
|
71
97
|
const getFileData = dataStorage.getJsonFile(checkedPath);
|
package/package.json
CHANGED
package/src/dataStorage.js
CHANGED
|
@@ -276,17 +276,34 @@ module.exports = {
|
|
|
276
276
|
},
|
|
277
277
|
|
|
278
278
|
/**
|
|
279
|
-
*
|
|
280
|
-
* @param format
|
|
281
|
-
* @param variable
|
|
282
|
-
* @param days
|
|
279
|
+
* Generate date with custom format in local timezone and store it in a variable
|
|
280
|
+
* @param format - date format
|
|
281
|
+
* @param variable - variable name
|
|
282
|
+
* @param days - number of days to add/subtract from the current date
|
|
283
283
|
* @returns {Promise<void>}
|
|
284
284
|
*/
|
|
285
285
|
generateAndSaveDateWithCustomFormat: async function (format, variable, days = 0) {
|
|
286
|
-
|
|
286
|
+
const date = moment()
|
|
287
287
|
.add(days >= 0 ? days : -days, 'days')
|
|
288
288
|
.format(format);
|
|
289
289
|
|
|
290
290
|
await this.iStoreVariableWithValueToTheJsonFile(date, variable);
|
|
291
291
|
},
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Generate date with custom format and timezone and store it in a variable
|
|
295
|
+
* THIS METHID IS NOT COMBINED WITH THE generateAndSaveDateWithCustomFormat due to ease of use in Gherkin steps.
|
|
296
|
+
* @param format - date format
|
|
297
|
+
* @param variable - variable name
|
|
298
|
+
* @param days - number of days to add/subtract from the current date
|
|
299
|
+
* @param offset - UTC offset in minutes (acceptable values are -240, -120, -60, 0, 60, 120, 240, etc.)
|
|
300
|
+
* @returns {Promise<void>}
|
|
301
|
+
*/
|
|
302
|
+
generateAndSaveDateWithCustomFormatAndTz: async function (format, variable, days = 0, offset = 0) {
|
|
303
|
+
const date = moment()
|
|
304
|
+
.utcOffset(offset)
|
|
305
|
+
.add(days >= 0 ? days : -days, 'days')
|
|
306
|
+
.format(format);
|
|
307
|
+
await this.iStoreVariableWithValueToTheJsonFile(date, variable);
|
|
308
|
+
},
|
|
292
309
|
};
|