-
Notifications
You must be signed in to change notification settings - Fork 4
/
data-flow-configurations-endpoint.spec.js
74 lines (55 loc) · 2.2 KB
/
data-flow-configurations-endpoint.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import sinon from "sinon";
import { expect } from "chai";
import {
getTransformationTaskConfigurations,
getTransformationTaskConfiguration,
updateTransformationTaskConfigurations,
transformationConfigs,
} from "../../../modeler-component/extensions/dataflow/configurations/TransformationTaskConfigurations";
import {
THREE_TRANSF_TASK_CONFIGS,
TWO_TRANSF_TASK_CONFIGS,
} from "./TransformationTaskConfigurations";
describe("Test the TransformationTaskConfigurationsEndpoint", function () {
let fetchStub;
before("Init ConfigurationEndpoint", function () {
const endpoint = transformationConfigs();
fetchStub = sinon.stub(endpoint, "fetchConfigurations").callsFake(() => {
endpoint.configurations = TWO_TRANSF_TASK_CONFIGS;
});
updateTransformationTaskConfigurations();
sinon.assert.calledOnce(fetchStub);
});
after(function () {
sinon.restore();
});
it("Should load two configurations", function () {
const configs = getTransformationTaskConfigurations();
expect(configs.length).to.equal(2);
const xmlTransfConfig = configs[0];
expect(xmlTransfConfig.name).to.equal("XML to JSON Transformation");
expect(xmlTransfConfig.id).to.equal("ID1");
expect(xmlTransfConfig.attributes.length).to.equal(1);
const csvTransfConfig = configs[1];
expect(csvTransfConfig.name).to.equal("CSV to JSON Transformation");
expect(csvTransfConfig.id).to.equal("ID2");
expect(csvTransfConfig.attributes.length).to.equal(3);
});
it("Should return correct configuration", function () {
const config = getTransformationTaskConfiguration("ID2");
expect(config.name).to.equal("CSV to JSON Transformation");
expect(config.id).to.equal("ID2");
expect(config.attributes.length).to.equal(3);
});
it("Should update configurations", function () {
let configs = getTransformationTaskConfigurations();
expect(configs.length).to.equal(2);
fetchStub.callsFake(() => {
transformationConfigs().configurations = THREE_TRANSF_TASK_CONFIGS;
});
updateTransformationTaskConfigurations();
sinon.assert.calledTwice(fetchStub);
configs = getTransformationTaskConfigurations();
expect(configs.length).to.equal(3);
});
});