Skip to Content
0
Former Member
Apr 26, 2018 at 06:47 PM

How to unit test sapui5 controls ?

102 Views Last edit Apr 27, 2018 at 08:13 AM 2 rev

Hi All, I am trying to write a unit test for the following code. Please guide the appropriate approach. This code was in the controller and moved it into the utility file so we can reuse it. How can I stub aSearchFormControls and do some assertion test? How can I stub controls and pass them as parameters in method enableControls() where their property setEnabled set to true which later I can test with assertions test.

 aSearchFormControls = [
                this.byId("a"),
                this.byId("b"),
                this.byId("c"),
            ];
    enableControls: function enableControls(aSearchFormControls ) {
            aControls.forEach(function enable(oControl) {
                oControl.setEnabled(true);
            });