Repository: angular/angular.js
File: test/ngAria/ariaSpec.js (JavaScript)

Code before:

    they('should not prevent default keyboard action if an interactive $type element' +
      'is nested inside ng-click', nodeBlackList, function(elementType) {
        function createHTML(type) {
          var html = '<' + type + '>';

          if (type === 'INPUT' || 'TYPE'  === 'A') {
            return html;
          }

          return html + '</' + type + '>';
        }

        compileElement(
          '<section>' +
            '<div ng-click="onClick($event)">' + createHTML(elementType) + '</div>' +
          '</section>');

        var divElement = element.find('div');
        var interactiveElement = element.find(elementType);

        // Use browserTrigger because it supports event bubbling
        browserTrigger(interactiveElement, 'keydown', {cancelable: true, bubbles: true, keyCode: 13});
        browserTrigger(interactiveElement, 'keydown', {cancelable: true, bubbles: true, keyCode: 32});

        expect(clickEvents).toEqual([elementType.toLowerCase() + '(false)',  elementType.toLowerCase() + '(false)']);
      }
    );

    it('should trigger a click in browsers that provide `event.which` instead of `event.keyCode`',
      function() {
        compileElement(
          '<section>' +
            '<div ng-click="onClick($event)"></div>' +
            '<ul><li ng-click="onClick($event)"></li></ul>' +
          '</section>');

        var divElement = element.find('div');
        var liElement = element.find('li');

        divElement.triggerHandler({type: 'keydown', which: 13});
        liElement.triggerHandler({type: 'keydown', which: 13});
        divElement.triggerHandler({type: 'keydown', which: 32});
        liElement.triggerHandler({type: 'keydown', which: 32});

        expect(clickEvents).toEqual(['div(true)', 'li(true)', 'div(true)', 'li(true)']);
      }
    );

    they('should not bind to key events if there is existing `ng-$prop`',
      ['keydown', 'keypress', 'keyup'], function(eventName) {

Review comment (suggestion):
I think the test would be a bit clearer if you checked `clickEvents` after each `browserTrigger`.
Otherwise someone might read this test as "you need to trigger two keydowns to get any events".

Code after:

    they('should not prevent default keyboard action if an interactive $type element' +
      'is nested inside ng-click', nodeBlackList, function(elementType) {
        function createHTML(type) {
          return '<' + type + '></' + type + '>';
        }

        compileElement(
          '<section>' +
            '<div ng-click="onClick($event)">' + createHTML(elementType) + '</div>' +
          '</section>');

        var divElement = element.find('div');
        var interactiveElement = element.find(elementType);

        // Use browserTrigger because it supports event bubbling
        // 13 Enter
        browserTrigger(interactiveElement, 'keydown', {cancelable: true, bubbles: true, keyCode: 13});
        expect(clickEvents).toEqual([elementType.toLowerCase() + '(false)']);

        clickEvents = [];

        // 32 Space
        browserTrigger(interactiveElement, 'keydown', {cancelable: true, bubbles: true, keyCode: 32});
        expect(clickEvents).toEqual([elementType.toLowerCase() + '(false)']);
      }
    );

    it('should trigger a click in browsers that provide `event.which` instead of `event.keyCode`',
      function() {
        compileElement(
          '<section>' +
            '<div ng-click="onClick($event)"></div>' +
            '<ul><li ng-click="onClick($event)"></li></ul>' +
          '</section>');

        var divElement = element.find('div');
        var liElement = element.find('li');

        divElement.triggerHandler({type: 'keydown', which: 13});
        liElement.triggerHandler({type: 'keydown', which: 13});
        divElement.triggerHandler({type: 'keydown', which: 32});
        liElement.triggerHandler({type: 'keydown', which: 32});

        expect(clickEvents).toEqual(['div(true)', 'li(true)', 'div(true)', 'li(true)']);
      }
    );

    they('should not bind to key events if there is existing `ng-$prop`',
      ['keydown', 'keypress', 'keyup'], function(eventName) {
        scope.onKeyEvent = jasmine.createSpy('onKeyEvent');