<commit_before>// Copyright 2015 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import componentsModule from 'common/components/components_module';

describe('Middle ellipsis directive', () => {
  /** @type {!angular.Scope} */
  let scope;
  /** @type {function(!angular.Scope):!angular.JQLite} */
  let compileFn;
  /** @type {!angular.$window} */
  let window;

  beforeEach(() => {
    angular.mock.module(componentsModule.name);

    angular.mock.inject(($rootScope, $compile, $window) => {
      scope = $rootScope.$new();
      window = $window;
      compileFn = $compile(`<div><kd-middle-ellipsis display-string="{{displayString}}"
          max-length="{{maxLength}}"></kd-middle-ellipsis></div>`);
    });
  });

  it('should show original display string', () => {
    // given
    let stringLength = 16;
    scope.displayString = new Array(stringLength + 1).join('x');
    let element = compileFn(scope);
    document.body.appendChild(element[0]);

    // when
    element[0].style.width = '500px';
    window.dispatchEvent(new Event('resize'));
    scope.$digest();

    // then
    expect(element.text().trim().length).toEqual(stringLength);

    // when
    element[0].style.width = '1px';
    window.dispatchEvent(new Event('resize'));
    scope.$digest();

    // then
    expect(element.text().trim().length).toEqual(0);

    // when
    element[0].style.width = '50px';
    window.dispatchEvent(new Event('resize'));<commit_msg>Fix IE test (#937)<commit_after>// Copyright 2015 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import componentsModule from 'common/components/components_module';

describe('Middle ellipsis directive', () => {
  /** @type {angular.Scope} */
  let scope;
  /** @type {function(!angular.Scope):!angular.JQLite} */
  let compileFn;
  /** @type {angular.$window} */
  let window;
  /** @type {Event} **/
  let resizeEvent;

  beforeEach(() => {
    angular.mock.module(componentsModule.name);

    angular.mock.inject(($rootScope, $compile, $window) => {
      resizeEvent = $window.document.createEvent('UIEvent');
      resizeEvent.initEvent('resize', true, false);
      scope = $rootScope.$new();
      window = $window;
      compileFn = $compile(`<div><kd-middle-ellipsis display-string="{{displayString}}"
          max-length="{{maxLength}}"></kd-middle-ellipsis></div>`);
    });
  });

  it('should show original display string', () => {
    // given
    let stringLength = 16;
    scope.displayString = new Array(stringLength + 1).join('x');
    let element = compileFn(scope);
    document.body.appendChild(element[0]);

    // when
    element[0].style.width = '500px';
    window.dispatchEvent(resizeEvent);
    scope.$digest();

    // then
    expect(element.text().trim().length).toEqual(stringLength);

    // when
    element[0].style.width = '1px';
    window.dispatchEvent(resizeEvent);
    scope.$digest();

    // then
    expect(element.text().trim().length).toEqual(0);

    // when
    element[0].style.width = '50px';
    window.dispatchEvent(resizeEvent);
{'fraction_non_alphanumeric': 0.15691037162982754, 'fraction_numerical': 0.011416079669662375, 'mean_word_length': 3.3715498938428876, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2501331', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1162, 'n_words': 320}