The examples in this article describe the usage of Angularjs Auxiliary library Browsertrigger. Share to everyone for your reference, specific as follows:
Today, we recommend a unit Test helper library from the Angularjs source code Browsertrigger, which comes from Ngscenario. The primary user triggers a browser-type behavior to update the value of the scope view model in NG.
This is an example of using Browsertrigger for unit testing in Angularjs source code:
It (' should set the model to empty string if empty option is selected ', function () {
Scope.robot = ' x ';
Compile (' <select ng-model= "robot" > ' +
' <option value= "" >--select--</option> ' +
' < Option value= "x" >robot x</option> ' +
' <option value= "y" >robot y</option> ' +
' </ Select> ');
Expect (Element). Toequalselect (', [' X '], ' y ');
Browsertrigger (element.find (' option '). EQ (0));
Expect (Element). Toequalselect (['], ' x ', ' y ');
Expect (Scope.robot). Tobe (');
});
In this code, give Browsertrigger the Select option you want to choose, it will help you tigger the change, select the current option, and trigger updates to the ViewModel of the NG Select.
We have also made a number of other input boxes or the triggering interface for HTML controls in the Browsertrigger, and also added browser compatibility. Make our tests more convenient without considering browser compatibility or different HTML controls trigger different events to update scope values.
For more information, you can refer to Ng's official test and Browsertrigger source code.
I hope this article will help you to Angularjs program design.