X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ui-react%2Fsrc%2Fcomponents%2Fdialogs%2FLoop%2FCreateLoopModal.test.js;h=5b6ea9e624f17a7f0c7078dbef997fdf92bd38fc;hb=c0ec0fc448af1c5d6eacb195e95938c921ba1bce;hp=18ec6fdce543cc6f6bc8fab42f4b379dfbe47c1c;hpb=515251fb5ce2d8f2b4ccb5bd5d3ebd46deb4d29a;p=clamp.git
diff --git a/ui-react/src/components/dialogs/Loop/CreateLoopModal.test.js b/ui-react/src/components/dialogs/Loop/CreateLoopModal.test.js
index 18ec6fdc..5b6ea9e6 100644
--- a/ui-react/src/components/dialogs/Loop/CreateLoopModal.test.js
+++ b/ui-react/src/components/dialogs/Loop/CreateLoopModal.test.js
@@ -30,8 +30,8 @@ describe('Verify CreateLoopModal', () => {
it('Test the render method', async () => {
const flushPromises = () => new Promise(setImmediate);
- TemplateService.getTemplateNames = jest.fn().mockImplementation(() => {
- return Promise.resolve(["template1","template2"]);
+ TemplateService.getAllLoopTemplates = jest.fn().mockImplementation(() => {
+ return Promise.resolve([{"name":"template1"},{"name":"template2"}]);
});
const component = shallow();
@@ -39,31 +39,26 @@ describe('Verify CreateLoopModal', () => {
await flushPromises();
component.update();
- expect(component.state('templateNames')).toStrictEqual([{"label": "template1", "value": "template1"}, {"label": "template2", "value": "template2"}]);
+ expect(component.state('templateNames')).toStrictEqual([{"label": "template1", "value": "template1", "templateObject": {"name": "template1"}}, {"label": "template2", "value": "template2","templateObject": {"name": "template2"}}]);
});
it('handleDropdownListChange event', async () => {
const flushPromises = () => new Promise(setImmediate);
- const event = {value: 'template1'};
- TemplateService.getBlueprintMicroServiceTemplateSvg = jest.fn().mockImplementation(() => {
- return Promise.resolve("");
- });
const component = shallow();
- component.find('StateManager').simulate('change', event);
+ component.find('StateManager').simulate('change', {value: 'template1', templateObject: {"name":"template1"} });
await flushPromises();
component.update();
expect(component.state('chosenTemplateName')).toEqual("template1");
- expect(component.state('content')).toEqual("Error1");
-
- TemplateService.getBlueprintMicroServiceTemplateSvg = jest.fn().mockImplementation(() => {
- return Promise.resolve("svgContentTest");
- });
- component.find('StateManager').simulate('change', {value: 'template2'});
+ expect(component.state('fakeLoopCacheWithTemplate').getLoopTemplate()['name']).toEqual("template1");
+ expect(component.state('fakeLoopCacheWithTemplate').getLoopName()).toEqual("fakeLoop");
+
+ component.find('StateManager').simulate('change',{value: 'template2', templateObject: {"name":"template2"} });
await flushPromises();
component.update();
expect(component.state('chosenTemplateName')).toEqual("template2");
- expect(component.state('content')).toEqual("svgContentTest");
+ expect(component.state('fakeLoopCacheWithTemplate').getLoopTemplate()['name']).toEqual("template2");
+ expect(component.state('fakeLoopCacheWithTemplate').getLoopName()).toEqual("fakeLoop");
});