<commit_before>import Ember from "ember";
import { test } from 'ember-qunit';
import startApp from '../helpers/start-app';
var App;

module('bm-select Acceptance Test', {
  setup: function() {
    App = startApp();
  },
  teardown: function() {
    Ember.run(App, App.destroy);
  }
});

test("bm-select Acceptance Test", function() {

  visit('/').then(function() {
    equal(find('bm-select bm-selected').text().trim(), "India", "bm-selected value is correctly set initially");

    //Initital click of bm-select
    find('bm-select').click();
    equal(find('bm-select').attr('aria-expanded'), "true", "bm-select aria-expanded is set to true on open");
    equal(find('bm-select bm-options').css('display'), "block", "Options drop down is visible on bm-select click");

    //Next click on bm-select
    find('bm-select').click();
    equal(find('bm-select').attr('aria-expanded'), "false", "bm-select aria-expanded is set to false on close");
    equal(find('bm-select bm-options').css('display'), "none", "Options drop down is hidden on next bm-select click");

    //Testing aria and keyboard navigation when opening dropdown
    find('bm-select').focus().trigger(keyDown(13));
    equal(find('bm-select').attr('aria-expanded'), "true", "bm-select aria-expanded is set to true on enter key press");
    equal(find('bm-select bm-options').css('display'), "block", "Options drop down is visible on enter key press");
    find('bm-select').click().trigger(keyDown(40));
    equal(find('bm-select').attr('aria-expanded'), "true", "bm-select aria-expanded is set to true on down arrow key press");
    equal(find('bm-select bm-options').css('display'), "block", "Options drop down is visible on down arrow key press");

    //Testing aria and keyboard navigation when closing dropdown
    find('bm-select').trigger(keyDown(27));
    equal(find('bm-select').attr('aria-expanded'), "false", "bm-select aria-expanded is set to false on escape key press");
    equal(find('bm-select bm-options').css('display'), "none", "Options drop down is hidden on escape key press");

    //Check selected bm-option
    var option = find('bm-select').find('bm-option[aria-checked=true]');
    equal(option.text().trim(), "India", "The correct bm-option has been checked");

    //Change selected option.
    var optionValue = find('bm-option:eq(1)').click().text().trim();
    var selectedOptionValue = find('bm-option[aria-checked=true]').text().trim();
    equal(optionValue, selectedOptionValue, "The correct bm-option has been checked after option click");
    find('bm-select').click().trigger(keyDown(38));
    optionValue = find('bm-option:eq(0)').click().text().trim();
    selectedOptionValue = find('bm-option[aria-checked=true]').text().trim();
    equal(optionValue, selectedOptionValue, "The correct bm-option has been checked after option keyboard navigation");

    //Check if component action is working
    var value = find('#country-value').text();
    equal(value, selectedOptionValue, "The actions from the component are triggered properly on option selection");<commit_msg>Added additional click to the tests so that the options menu is closed before teardown. Without this the tests will fail.<commit_after>import Ember from "ember";
import { test } from 'ember-qunit';
import startApp from '../helpers/start-app';
var App;

module('bm-select Acceptance Test', {
  setup: function() {
    App = startApp();
  },
  teardown: function() {
    Ember.run(App, App.destroy);
  }
});

test("bm-select Acceptance Test", function() {

  visit('/').then(function() {
    equal(find('bm-select bm-selected').text().trim(), "India", "bm-selected value is correctly set initially");

    //Initital click of bm-select
    find('bm-select').click();
    equal(find('bm-select').attr('aria-expanded'), "true", "bm-select aria-expanded is set to true on open");
    equal(find('bm-select bm-options').css('display'), "block", "Options drop down is visible on bm-select click");

    //Next click on bm-select
    find('bm-select').click();
    equal(find('bm-select').attr('aria-expanded'), "false", "bm-select aria-expanded is set to false on close");
    equal(find('bm-select bm-options').css('display'), "none", "Options drop down is hidden on next bm-select click");

    //Testing aria and keyboard navigation when opening dropdown
    find('bm-select').focus().trigger(keyDown(13));
    equal(find('bm-select').attr('aria-expanded'), "true", "bm-select aria-expanded is set to true on enter key press");
    equal(find('bm-select bm-options').css('display'), "block", "Options drop down is visible on enter key press");
    find('bm-select').click().trigger(keyDown(40));
    equal(find('bm-select').attr('aria-expanded'), "true", "bm-select aria-expanded is set to true on down arrow key press");
    equal(find('bm-select bm-options').css('display'), "block", "Options drop down is visible on down arrow key press");

    //Testing aria and keyboard navigation when closing dropdown
    find('bm-select').trigger(keyDown(27));
    equal(find('bm-select').attr('aria-expanded'), "false", "bm-select aria-expanded is set to false on escape key press");
    equal(find('bm-select bm-options').css('display'), "none", "Options drop down is hidden on escape key press");

    //Check selected bm-option
    var option = find('bm-select').find('bm-option[aria-checked=true]');
    equal(option.text().trim(), "India", "The correct bm-option has been checked");

    //Change selected option.
    var optionValue = find('bm-option:eq(1)').click().text().trim();
    var selectedOptionValue = find('bm-option[aria-checked=true]').text().trim();
    equal(optionValue, selectedOptionValue, "The correct bm-option has been checked after option click");
    find('bm-select').click().trigger(keyDown(38));
    optionValue = find('bm-option:eq(0)').click().text().trim();
    selectedOptionValue = find('bm-option[aria-checked=true]').text().trim();
    equal(optionValue, selectedOptionValue, "The correct bm-option has been checked after option keyboard navigation");

    //Check if component action is working
    var value = find('#country-value').text();
    equal(value, selectedOptionValue, "The actions from the component are triggered properly on option selection");

    //click bm-select to close the options or will break the tests.
    //The teardown method of tests will trigger a focusout event on bm-select.
    //If the options menu is closed then the focusout event will trigger with no side effects.
    click('bm-select');

{'fraction_non_alphanumeric': 0.16549295774647887, 'fraction_numerical': 0.003061849357011635, 'mean_word_length': 4.412593206296603, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5432338', 'n_tokens_mistral': 1893, 'n_tokens_neox': 1861, 'n_words': 575}