ANGULARJS Auxiliary Library Browsertrigger Usage Example _angularjs

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.