Added some tests for the Translate DateTime Format operation

This commit is contained in:
Cynser 2018-08-16 03:28:11 +01:00
parent 1a1fad7433
commit f1c31ea966
2 changed files with 57 additions and 0 deletions

View File

@ -62,6 +62,7 @@ import "./tests/operations/SetDifference";
import "./tests/operations/SetIntersection";
import "./tests/operations/SetUnion";
import "./tests/operations/SymmetricDifference";
import "./tests/operations/TranslateDateTimeFormat";
import "./tests/operations/Magic";
let allTestsPassing = true;

View File

@ -0,0 +1,56 @@
/**
* Translate DateTime Format tests.
*
* @author Cynser
*
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../../TestRegister";
TestRegister.addTests([
{
name: "Translate DateTime Format",
input: "01/04/1999 22:33:01",
expectedOutput: "Thursday 1st April 1999 22:33:01 +00:00 UTC",
recipeConfig: [
{
op: "Translate DateTime Format",
args: ["Standard date and time", "DD/MM/YYYY HH:mm:ss", "UTC", "dddd Do MMMM YYYY HH:mm:ss Z z", "UTC"],
},
],
},
{
name: "Translate DateTime Format: invalid input",
input: "1234567890",
expectedMatch: /Invalid format./,
recipeConfig: [
{
op: "Translate DateTime Format",
args: ["Standard date and time", "DD/MM/YYYY HH:mm:ss", "UTC", "dddd Do MMMM YYYY HH:mm:ss Z z", "UTC"],
},
],
},
{
name: "Translate DateTime Format: timezone conversion",
input: "01/04/1999 22:33:01",
expectedOutput: "Thursday 1st April 1999 17:33:01 -05:00 EST",
recipeConfig: [
{
op: "Translate DateTime Format",
args: ["Standard date and time", "DD/MM/YYYY HH:mm:ss", "UTC", "dddd Do MMMM YYYY HH:mm:ss Z z", "US/Eastern"],
},
],
},
{
name: "Translate DateTime Format: automatic input format",
input: "1999-04-01 22:33:01",
expectedOutput: "Thursday 1st April 1999 22:33:01 +00:00 UTC",
recipeConfig: [
{
op: "Translate DateTime Format",
args: ["Automatic", "", "UTC", "dddd Do MMMM YYYY HH:mm:ss Z z", "UTC"],
},
],
}
]);