<commit_before>describe('sample test', function(){

  angular.module('greeting-app', [])
    .directive('greeting', function(){
      return {
        template: ['<div>',
                    '<input class="name" type=text ng-model="name">',
                    '<button ng-click="vm.sayHello()">Say Hello</button>',
                    '<span class="greeting">{{message}}',
                   '</div>'].join(),
        scope: {
          name: '='
        },
        controllerAs: 'vm',
        controller: function($http, $scope){
          this.sayHello = function(){
            $http.post('/greeting', { name: $scope.name })
              .success(function(json){
                $scope.message = json.greeting;
              });
          }
        }
      };
    });

  var server, app;
  var type = testRunner.actions.type;
  var click = testRunner.actions.click;
  var expect = testRunner.actions.expectElement;

  beforeEach(function(){

    app = testRunner.app(['greeting-app']);
    server = testRunner.http();
  });

  afterEach(function () {
    server.stop();
  });

  beforeEach(function(){
    server.post('/greeting', function(req){
      
      var body = req.body();
      
      req.sendJson({
        greeting: 'Hello ' + body.name + '!'
      });
    });
  });
  
  it('populates name with default value', function(){
    
    // given:
    var html = app.runHtml('<greeting name="defaultName"/>', {defaultName: 'John'});
    
    // then:
    html.verify(
        expect('input.name').toHaveValue('John')
    );
    
  });

  it('greets person', function(){
    
    // given:
    var html = app.runHtml('<greeting name="defaultName"/>', {defaultName: 'John'});
      
    // when:
    html.perform(
        type('Jane').in('input.name'),
        click.in('button')
    );
    
    // then:
    html.verify(
        expect('.greeting').toContainText('Hello Jane!')
    );
    
  });

});<commit_msg>verify that keydown works<commit_after>describe('sample test', function(){

  angular.module('greeting-app', [])
    .directive('greeting', function(){
      return {
        template: ['<form ng-submit="vm.sayHello()">',
                    '<input class="name" type=text ng-model="name">',
                    '<button type="submit">Say Hello</button>',
                    '<span class="greeting">{{message}}</span>',
                   '</form>'].join(),
        scope: {
          name: '='
        },
        controllerAs: 'vm',
        controller: function($http, $scope){
          this.sayHello = function(){

            $http.post('/greeting', { name: $scope.name })
              .success(function(json){
                $scope.message = json.greeting;
              });
          }
        },
        link: function(scope, element){
          element.find('input').on('keydown', function(ev){
            if(ev.which === 13){
              scope.vm.sayHello();
            }
          });
        }
      };
    });

  var server, app;
  var type = testRunner.actions.type;
  var click = testRunner.actions.click;
  var expect = testRunner.actions.expectElement;
  var keydown = testRunner.actions.keydown;

  beforeEach(function(){

    app = testRunner.app(['greeting-app']);
    server = testRunner.http();
  });

  afterEach(function () {
    server.stop();
  });

  beforeEach(function(){
    server.post('/greeting', function(req){

      var body = req.body();
      req.sendJson({
        greeting: 'Hello ' + body.name + '!'
      });
    });
  });
  
  it('populates name with default value', function(){
    
    // given:
    var html = app.runHtml('<greeting name="defaultName"/>', {defaultName: 'John'});
    
    // then:
    html.verify(
        expect('input.name').toHaveValue('John')
    );
    
  });

  it('greets person', function(){
    
    // given:
    var html = app.runHtml('<greeting name="defaultName"/>', {defaultName: 'John'});
      
    // when:
    html.perform(
        type('Jane').in('input.name'),
        click.in('button')
    );
    
    // then:
    html.verify(
        expect('.greeting').toContainText('Hello Jane!')
    );
    
  });

  it('greets person on enter', function(){
    // given:
    var html = app.runHtml('<greeting name="defaultName"/>', {defaultName: 'John'});

    // when:
    html.perform(
        type('Jane').in('input.name'),
        keydown(13).in('input.name')
    );

    // then:
    html.verify(
        expect('.greeting').toContainText('Hello Jane!')
    );

  });


});
{'fraction_non_alphanumeric': 0.18473895582329317, 'fraction_numerical': 0.000892458723784025, 'mean_word_length': 1.9866755496335775, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7107984', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1353, 'n_words': 229}