@catladder/pipeline
Version:
Panter workflow for cloud CI/CD and DevOps
36 lines (35 loc) • 2.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var VariableValueContainingReferences_1 = require("../VariableValueContainingReferences");
describe("createVarialeValueFromString", function () {
it("should create a VariableValue from a simple string", function () {
var stringValue = "hello world";
var result = (0, VariableValueContainingReferences_1.createVariableValueContainingReferencesFromString)(stringValue, {
componentName: "myComponent"
});
expect(result.parts).toEqual([stringValue]);
});
it("extracts references to other components", function () {
var stringValue = "the other component has ${otherComponent:variableName}, isn't that cool?";
var result = (0, VariableValueContainingReferences_1.createVariableValueContainingReferencesFromString)(stringValue, {
componentName: "myComponent"
});
expect(result.parts).toEqual(["the other component has ", new VariableValueContainingReferences_1.VariableReference("otherComponent", "variableName"), ", isn't that cool?"]);
});
it("extracts self references", function () {
var stringValue = "my component has ${variableName}!";
var result = (0, VariableValueContainingReferences_1.createVariableValueContainingReferencesFromString)(stringValue, {
componentName: "myComponent"
});
expect(result.parts).toEqual(["my component has ", new VariableValueContainingReferences_1.VariableReference("myComponent", "variableName"), "!"]);
});
it("extracts multiple references", function () {
var stringValue = "my component has ${variableName} and the other component has ${otherComponent:variableName}!";
var result = (0, VariableValueContainingReferences_1.createVariableValueContainingReferencesFromString)(stringValue, {
componentName: "myComponent"
});
expect(result.parts).toEqual(["my component has ", new VariableValueContainingReferences_1.VariableReference("myComponent", "variableName"), " and the other component has ", new VariableValueContainingReferences_1.VariableReference("otherComponent", "variableName"), "!"]);
});
});