<commit_before>describe 'fsSelect', ->
  $scope = null
  $compile = null

  beforeEach module('formstamp')

  beforeEach inject ($rootScope, _$compile_) ->
    $scope = $rootScope.$new()
    $scope.items = ['first', 'second', 'last']
    $compile = _$compile_

  compile = (elem) ->
    elem ||= '<div fs-select items="items" ng-model="value"></div>'
    element = $compile(elem)($scope)
    $scope.$apply()
    element

  it 'should expands', ->
    element = compile()
    expect(element.children().length).not.toBe 0

  it 'should disable input on ngDisabled', ->
    element = compile('<div fs-select items="items" ng-disabled="true"></div>')
    $scope.$apply()
    expect(element.find('input').prop('disabled')).toBeDefined()

  it 'should propagate classes to widget root', ->
    element = compile('<div fs-select items="items" class="someclass"></div>')
    $scope.$apply()
    expect(element.attr('class')).toMatch /someclass/

  it 'should update scope property', ->
    element = compile('<div fs-select ng-model="value" items="items"></div>')
    $scope.$apply()
    input = element.find('input')
    input.val($scope.items.first).triggerHandler('input')

    expect($scope.value).toBe $scope.items.first

  it 'should clear scope value when "x" button is pressed', ->
    element = compile('<div fs-select ng-model="value" items="items"></div>')
    $scope.$apply(-> $scope.value = $scope.items.first)
    expect($scope.value).toBe $scope.items.first

    element.find('.fs-select-clear-btn').click()
    expect($scope.value).toBe(null)
<commit_msg>tests for fsSelect<commit_after>describe 'fsSelect', ->
  $scope = null
  $compile = null

  beforeEach module('formstamp')

  beforeEach inject ($rootScope, _$compile_) ->
    $scope = $rootScope.$new()
    $scope.items = ['first', 'second', 'last']
    $compile = _$compile_

  compile = (elem) ->
    elem ||= '<div fs-select items="items" ng-model="value"></div>'
    element = $compile(elem)($scope)
    $scope.$apply()
    element

  it 'should expands', ->
    element = compile()
    expect(element.children().length).not.toBe 0

  it 'should disable input on ngDisabled', ->
    element = compile('<div fs-select items="items" ng-disabled="true"></div>')
    $scope.$apply()
    expect(element.find('input').prop('disabled')).toBeDefined()

  it 'should propagate classes to widget root', ->
    element = compile('<div fs-select items="items" class="someclass"></div>')
    $scope.$apply()
    expect(element.attr('class')).toMatch /someclass/

  it 'should update scope property', ->
    element = compile('<div fs-select ng-model="value" items="items"></div>')
    $scope.$apply()
    input = element.find('input')
    input.val($scope.items.first).triggerHandler('input')

    expect($scope.value).toBe $scope.items.first

  it 'should clear scope value when "x" button is pressed', ->
    element = compile('<div fs-select ng-model="value" items="items"></div>')
    $scope.$apply(-> $scope.value = $scope.items.first)
    expect($scope.value).toBe $scope.items.first

    element.find('.fs-select-clear-btn').click()
    expect($scope.value).toBe(null)

  it 'should set scope value as it were in items array', ->
    $scope.items = [
      { id: 1, label: "first" },
      { id: 2, label: "second" }
    ]

    element = compile('<div fs-select ng-model="value" items="items">{{ item.label }}</div>')
    $scope.$apply(-> $scope.value = $scope.items.first)
    expect($scope.value).toBe $scope.items.first

{'fraction_non_alphanumeric': 0.1890961262553802, 'fraction_numerical': 0.0011477761836441894, 'mean_word_length': 3.710810810810811, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 45, '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': '4010937', 'n_tokens_mistral': 1091, 'n_tokens_neox': 1062, 'n_words': 242}