<commit_before>'use strict';

var helper    = require('./helper')
  , should    = require('should')

var browser

before(function(done) {
    helper.getBrowser(function(driver) {
        browser = driver
        browser.get('http://127.0.0.1:8080/test/test.html')
            .then(function() { done() })
    })
})

beforeEach(function(done) {
    browser.input('#test1').clear()
    browser.element('#test1').then(function() { done() })
})

after(function(done) {
    browser.quit().then(function() {
        helper.stopServer(done)
    })
})

describe('Lookups', function() {
    
  it('Performs a simple lookup', function(done) {

    browser.element('#test1').sendKeys('M')
    browser.elements('div.autocomplete div').count(function(length) {
      length.should.equal(0)
    })
    browser.element('#test1').sendKeys('a')
    browser.elements('div.autocomplete div').count(function(length) {
      length.should.equal(2)
    })
    browser.element('div.autocomplete div').html(function(html) {
      html.should.equal('<strong>Ma</strong>rch')
    })
    browser.element('#test1').sendKeys('r')
    browser.elements('div.autocomplete div').count(function(length) {
      length.should.equal(1)
    })
    browser.element('div.autocomplete div').html(function(html) {
      html.should.equal('<strong>Mar</strong>ch')
      done()
    })
  })
  
  it('Adds \'selected\' CSS class when item selected with down arrow', function(done) {
    browser.element('#test1').sendKeys('March')
    browser.elements('div.autocomplete div').count(function(length) {
      length.should.equal(1)
    })

    browser.element('#test1').sendKeys(helper.Webdriver.Key.ARROW_DOWN)
    browser.element('div.autocomplete div.selected').html(function(html) {
        html.should.include('<strong>March</strong>')
        done()
    })
  })

})

describe('Autocomplete fill', function() {
  
    it('Updates text box when clicking a value', function(done) {
        browser.element('#test1').sendKeys('Ma')
        browser.element('div.autocomplete div[title="March"]').click()
        browser.input('input#test1').value(function(value) {
            value.should.equal('March')
            done()
        })
    })
    
})<commit_msg>Add test for autofill<commit_after>'use strict';

var helper    = require('./helper')
  , should    = require('should')

var browser

before(function(done) {
    helper.getBrowser(function(driver) {
        browser = driver
        browser.get('http://127.0.0.1:8080/test/test.html')
            .then(function() { done() })
    })
})

beforeEach(function(done) {
    browser.input('#test1').clear()
    browser.element('#test1').then(function() { done() })
})

after(function(done) {
    browser.quit().then(function() {
        helper.stopServer(done)
    })
})

describe('Lookups', function() {
    
  it('Performs a simple lookup', function(done) {

    browser.element('#test1').sendKeys('M')
    browser.elements('div.autocomplete div').count(function(length) {
      length.should.equal(0)
    })
    browser.element('#test1').sendKeys('a')
    browser.elements('div.autocomplete div').count(function(length) {
      length.should.equal(2)
    })
    browser.element('div.autocomplete div').html(function(html) {
      html.should.equal('<strong>Ma</strong>rch')
    })
    browser.element('#test1').sendKeys('r')
    browser.elements('div.autocomplete div').count(function(length) {
      length.should.equal(1)
    })
    browser.element('div.autocomplete div').html(function(html) {
      html.should.equal('<strong>Mar</strong>ch')
      done()
    })
  })
  
  it('Adds \'selected\' CSS class when item selected with down arrow', function(done) {
    browser.element('#test1').sendKeys('March')
    browser.elements('div.autocomplete div').count(function(length) {
      length.should.equal(1)
    })

    browser.element('#test1').sendKeys(helper.Webdriver.Key.ARROW_DOWN)
    browser.element('div.autocomplete div.selected').html(function(html) {
        html.should.include('<strong>March</strong>')
        done()
    })
  })

})

describe('Autocomplete fill', function() {
  
    it('Updates text box as I select values with arrow keys', function(done) {
        browser.element('#test1').sendKeys('Ma')
        browser.element('#test1').sendKeys(helper.Webdriver.Key.ARROW_DOWN)
        browser.input('#test1').value(function(value) {
            value.should.equal('March')
        })
        browser.element('#test1').sendKeys(helper.Webdriver.Key.ARROW_DOWN)
        browser.input('#test1').value(function(value) {
            value.should.equal('May')
        })
        browser.element('#test1').sendKeys(helper.Webdriver.Key.ARROW_UP)
        browser.input('#test1').value(function(value) {
            value.should.equal('March')
            done()
        }) 
    })
    
    it('Updates text box when clicking a value', function(done) {
        browser.element('#test1').sendKeys('Ma')
        browser.element('div.autocomplete div[title="March"]').click()
        browser.input('input#test1').value(function(value) {
            value.should.equal('March')
            done()
        })
    })
    
})
{'fraction_non_alphanumeric': 0.17862001943634598, 'fraction_numerical': 0.010301263362487852, 'mean_word_length': 3.1871440195280716, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2167710', 'n_tokens_mistral': 1608, 'n_tokens_neox': 1556, 'n_words': 197}