From 233e3cdba0aec0f0c21cc5986654feb33cb7eb3d Mon Sep 17 00:00:00 2001 From: xuegao Date: Tue, 1 Oct 2019 15:34:53 +0200 Subject: Add react ui tests Add more tests for react UI. Issue-ID: CLAMP-509 Change-Id: I58f6408bcd8667fa8b16b0b2f31f8287bdfac8c9 Signed-off-by: xuegao --- .../components/loop_viewer/logs/LoopLogs.test.js | 24 +++++++++++++++++++++- .../loop_viewer/status/LoopStatus.test.js | 24 ++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) (limited to 'ui-react/src/components/loop_viewer') diff --git a/ui-react/src/components/loop_viewer/logs/LoopLogs.test.js b/ui-react/src/components/loop_viewer/logs/LoopLogs.test.js index 3c76405c4..5c478f6a5 100644 --- a/ui-react/src/components/loop_viewer/logs/LoopLogs.test.js +++ b/ui-react/src/components/loop_viewer/logs/LoopLogs.test.js @@ -42,7 +42,29 @@ describe('Verify LoopLogs', () => { it('Test the render method', () => { const component = shallow() - expect(component).toMatchSnapshot(); + + const loopCacheUpdated = new LoopCache({ + "name": "LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca", + "loopLogs": [ + { + "id": 1, + "logType": "INFO", + "logComponent": "CLAMP", + "message": "Operational and Guard policies UPDATED", + "logInstant": "2019-07-08T09:44:37Z" + }, + { + "id": 2, + "logType": "INFO", + "logComponent": "CLAMP", + "message": "Operational and Guard policies UPDATED", + "logInstant": "2019-07-08T09:44:50Z" + } + ] + }); + + component.setProps({ loopCache: loopCacheUpdated }); + expect(component.find('TableRow').length).toEqual(2); }); }); \ No newline at end of file diff --git a/ui-react/src/components/loop_viewer/status/LoopStatus.test.js b/ui-react/src/components/loop_viewer/status/LoopStatus.test.js index 2be825edc..8d0448796 100644 --- a/ui-react/src/components/loop_viewer/status/LoopStatus.test.js +++ b/ui-react/src/components/loop_viewer/status/LoopStatus.test.js @@ -50,5 +50,29 @@ describe('Verify LoopStatus', () => { const component = shallow() expect(component).toMatchSnapshot(); + + const loopCacheUpdated = new LoopCache({ + "name": "LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca", + "lastComputedState": "SUBMIT", + "components": { + "POLICY": { + "componentState": { + "stateName": "SENT", + "description": "The policies defined have NOT yet been created on the policy engine" + } + }, + "DCAE": { + "componentState": { + "stateName": "BLUEPRINT_DEPLOYED", + "description": "The DCAE blueprint has been found in the DCAE inventory but not yet instancianted for this loop" + } + } + } + }); + component.setProps({ loopCache: loopCacheUpdated }); + + const forms = component.find('TableRow'); + expect(forms.get(0).props.statusRow.stateName).toEqual("SENT"); + expect(component.find('label').text()).toContain('SUBMIT'); }); }); \ No newline at end of file -- cgit 1.2.3-korg