Fix tests.
This commit is contained in:
parent
669b0743ac
commit
67a848bb86
|
@ -5,10 +5,10 @@ if [[ -n $CI ]]
|
||||||
then
|
then
|
||||||
# Running in ci, where resources are limited
|
# Running in ci, where resources are limited
|
||||||
export NODE_OPTIONS="--max-old-space-size=4096"
|
export NODE_OPTIONS="--max-old-space-size=4096"
|
||||||
echo "jest --coverage --maxWorkers=2 --forceExit --workerIdleMemoryLimit=2000MB --bail"
|
echo "jest --coverage --maxWorkers=2 --forceExit --workerIdleMemoryLimit=2000MB --bail $@"
|
||||||
jest --coverage --maxWorkers=2 --forceExit --workerIdleMemoryLimit=2000MB --bail
|
jest --coverage --maxWorkers=2 --forceExit --workerIdleMemoryLimit=2000MB --bail $@
|
||||||
else
|
else
|
||||||
# --maxWorkers performs better in development
|
# --maxWorkers performs better in development
|
||||||
echo "jest --coverage --maxWorkers=2 --forceExit"
|
echo "jest --coverage --maxWorkers=2 --forceExit $@"
|
||||||
jest --coverage --maxWorkers=2 --forceExit
|
jest --coverage --maxWorkers=2 --forceExit $@
|
||||||
fi
|
fi
|
|
@ -1,10 +1,15 @@
|
||||||
const automationUtils = require("../automationUtils")
|
import { LoopStep, LoopStepType } from "../../definitions/automations"
|
||||||
|
import {
|
||||||
|
typecastForLooping,
|
||||||
|
cleanInputValues,
|
||||||
|
substituteLoopStep,
|
||||||
|
} from "../automationUtils"
|
||||||
|
|
||||||
describe("automationUtils", () => {
|
describe("automationUtils", () => {
|
||||||
describe("substituteLoopStep", () => {
|
describe("substituteLoopStep", () => {
|
||||||
it("should allow multiple loop binding substitutes", () => {
|
it("should allow multiple loop binding substitutes", () => {
|
||||||
expect(
|
expect(
|
||||||
automationUtils.substituteLoopStep(
|
substituteLoopStep(
|
||||||
`{{ loop.currentItem._id }} {{ loop.currentItem._id }} {{ loop.currentItem._id }}`,
|
`{{ loop.currentItem._id }} {{ loop.currentItem._id }} {{ loop.currentItem._id }}`,
|
||||||
"step.2"
|
"step.2"
|
||||||
)
|
)
|
||||||
|
@ -15,7 +20,7 @@ describe("automationUtils", () => {
|
||||||
|
|
||||||
it("should handle not subsituting outside of curly braces", () => {
|
it("should handle not subsituting outside of curly braces", () => {
|
||||||
expect(
|
expect(
|
||||||
automationUtils.substituteLoopStep(
|
substituteLoopStep(
|
||||||
`loop {{ loop.currentItem._id }}loop loop{{ loop.currentItem._id }}loop`,
|
`loop {{ loop.currentItem._id }}loop loop{{ loop.currentItem._id }}loop`,
|
||||||
"step.2"
|
"step.2"
|
||||||
)
|
)
|
||||||
|
@ -28,37 +33,32 @@ describe("automationUtils", () => {
|
||||||
describe("typeCastForLooping", () => {
|
describe("typeCastForLooping", () => {
|
||||||
it("should parse to correct type", () => {
|
it("should parse to correct type", () => {
|
||||||
expect(
|
expect(
|
||||||
automationUtils.typecastForLooping(
|
typecastForLooping({
|
||||||
{ inputs: { option: "Array" } },
|
inputs: { option: LoopStepType.ARRAY, binding: [1, 2, 3] },
|
||||||
{ binding: [1, 2, 3] }
|
} as LoopStep)
|
||||||
)
|
|
||||||
).toEqual([1, 2, 3])
|
).toEqual([1, 2, 3])
|
||||||
expect(
|
expect(
|
||||||
automationUtils.typecastForLooping(
|
typecastForLooping({
|
||||||
{ inputs: { option: "Array" } },
|
inputs: { option: LoopStepType.ARRAY, binding: "[1,2,3]" },
|
||||||
{ binding: "[1, 2, 3]" }
|
} as LoopStep)
|
||||||
)
|
|
||||||
).toEqual([1, 2, 3])
|
).toEqual([1, 2, 3])
|
||||||
expect(
|
expect(
|
||||||
automationUtils.typecastForLooping(
|
typecastForLooping({
|
||||||
{ inputs: { option: "String" } },
|
inputs: { option: LoopStepType.STRING, binding: [1, 2, 3] },
|
||||||
{ binding: [1, 2, 3] }
|
} as LoopStep)
|
||||||
)
|
|
||||||
).toEqual("1,2,3")
|
).toEqual("1,2,3")
|
||||||
})
|
})
|
||||||
it("should handle null values", () => {
|
it("should handle null values", () => {
|
||||||
// expect it to handle where the binding is null
|
// expect it to handle where the binding is null
|
||||||
expect(
|
expect(
|
||||||
automationUtils.typecastForLooping(
|
typecastForLooping({
|
||||||
{ inputs: { option: "Array" } },
|
inputs: { option: LoopStepType.ARRAY },
|
||||||
{ binding: null }
|
} as LoopStep)
|
||||||
)
|
|
||||||
).toEqual(null)
|
).toEqual(null)
|
||||||
expect(() =>
|
expect(() =>
|
||||||
automationUtils.typecastForLooping(
|
typecastForLooping({
|
||||||
{ inputs: { option: "Array" } },
|
inputs: { option: LoopStepType.ARRAY, binding: "test" },
|
||||||
{ binding: "test" }
|
} as LoopStep)
|
||||||
)
|
|
||||||
).toThrow()
|
).toThrow()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -80,7 +80,7 @@ describe("automationUtils", () => {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
expect(
|
expect(
|
||||||
automationUtils.cleanInputValues(
|
cleanInputValues(
|
||||||
{
|
{
|
||||||
row: {
|
row: {
|
||||||
relationship: `[{"_id": "ro_ta_users_us_3"}]`,
|
relationship: `[{"_id": "ro_ta_users_us_3"}]`,
|
||||||
|
@ -113,7 +113,7 @@ describe("automationUtils", () => {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
expect(
|
expect(
|
||||||
automationUtils.cleanInputValues(
|
cleanInputValues(
|
||||||
{
|
{
|
||||||
row: {
|
row: {
|
||||||
relationship: `ro_ta_users_us_3`,
|
relationship: `ro_ta_users_us_3`,
|
||||||
|
|
|
@ -11,7 +11,7 @@ export interface LoopStep extends AutomationStep {
|
||||||
|
|
||||||
export interface LoopInput {
|
export interface LoopInput {
|
||||||
option: LoopStepType
|
option: LoopStepType
|
||||||
binding: string[] | string
|
binding?: string[] | string | number[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TriggerOutput {
|
export interface TriggerOutput {
|
||||||
|
|
Loading…
Reference in New Issue