<commit_before>import ToastModule from "../../src/xing-frontend-utils/components/toast/toast.js";
import {bootstrap} from "a1atscript";

xdescribe('$lrdToast service', function() {
  beforeEach(function() {
    bootstrap(ToastModule);
    angular.mock.module(`toast`, 'ngAnimateMock', function($provide) {
    })
  });

  function setup(options) {
    inject(function($lrdToast, $rootScope, $animate) {
      options = options || {};
      $lrdToast.show(options);
      $rootScope.$apply();
      $animate.triggerCallbacks();
    });
  }

  describe('options', function() {

    it('should hide after duration', inject(function($timeout, $animate, $rootElement) {
      var parent = angular.element('<div>');
      setup({
        template: '<lrd-toast />',
        hideTimeout: 1234
      });
      expect($rootElement.find('lrd-toast').length).toBe(1);
      $timeout.flush();
      expect($rootElement.find('lrd-toast').length).toBe(0);
    }));

    it('should have template', inject(function($timeout, $rootScope, $rootElement) {
      var parent = angular.element('<div>');
      setup({
        template: '<lrd-toast>{{1}}234</lrd-toast>',
        appendTo: parent
      });
      var toast = $rootElement.find('lrd-toast');
      $timeout.flush();
      expect(toast.text()).toBe('1234');
    }));

    it('should have templateUrl', inject(function($timeout, $rootScope, $templateCache, $rootElement) {
      $templateCache.put('template.html', '<lrd-toast>hello, {{1}}</lrd-toast>');
      setup({
        templateUrl: 'template.html',
      });
      var toast = $rootElement.find('lrd-toast');
      expect(toast.text()).toBe('hello, 1');
    }));
  });

  describe('lifecycle', function() {

    it('should hide current toast when showing new one', inject(function($rootElement) {
      setup({
        template: '<lrd-toast class="one">'
      });
      expect($rootElement.find('lrd-toast.one').length).toBe(1);
      expect($rootElement.find('lrd-toast.two').length).toBe(0);
      expect($rootElement.find('lrd-toast.three').length).toBe(0);

      setup({
        template: '<lrd-toast class="two">'
      });
      expect($rootElement.find('lrd-toast.one').length).toBe(0);
      expect($rootElement.find('lrd-toast.two').length).toBe(1);
      expect($rootElement.find('lrd-toast.three').length).toBe(0);

      setup({
        template: '<lrd-toast class="three">'
      });
      expect($rootElement.find('lrd-toast.one').length).toBe(0);
      expect($rootElement.find('lrd-toast.two').length).toBe(0);
      expect($rootElement.find('lrd-toast.three').length).toBe(1);
    }));

    it('should add class to toastParent', inject(function($rootElement) {
      setup({
        template: '<lrd-toast>'
      });
      expect($rootElement.hasClass('lrd-toast-open-bottom')).toBe(true);

      setup({
        template: '<lrd-toast>',
        position: 'top'
      });
      expect($rootElement.hasClass('lrd-toast-open-top')).toBe(true);
    }));<commit_msg>Renames lrdToast to xngToast in testing.<commit_after>import ToastModule from "../../src/xing-frontend-utils/components/toast/toast.js";
import {bootstrap} from "a1atscript";

describe('$xngToast service', function() {
  beforeEach(function() {
    bootstrap(ToastModule);
    angular.mock.module(`toast`, 'ngAnimateMock', function($provide) {
    })
  });

  function setup(options) {
    inject(function($xngToast, $rootScope, $animate) {
      options = options || {};
      $xngToast.show(options);
      $rootScope.$apply();
      $animate.triggerCallbacks();
    });
  }

  describe('options', function() {

    it('should hide after duration', inject(function($timeout, $animate, $rootElement) {
      var parent = angular.element('<div>');
      setup({
        template: '<xng-toast />',
        hideTimeout: 1234
      });
      expect($rootElement.find('xng-toast').length).toBe(1);
      $timeout.flush();
      expect($rootElement.find('xng-toast').length).toBe(0);
    }));

    it('should have template', inject(function($timeout, $rootScope, $rootElement) {
      var parent = angular.element('<div>');
      setup({
        template: '<xng-toast>{{1}}234</xng-toast>',
        appendTo: parent
      });
      var toast = $rootElement.find('xng-toast');
      $timeout.flush();
      expect(toast.text()).toBe('1234');
    }));

    it('should have templateUrl', inject(function($timeout, $rootScope, $templateCache, $rootElement) {
      $templateCache.put('template.html', '<xng-toast>hello, {{1}}</xng-toast>');
      setup({
        templateUrl: 'template.html',
      });
      var toast = $rootElement.find('xng-toast');
      expect(toast.text()).toBe('hello, 1');
    }));
  });

  describe('lifecycle', function() {

    it('should hide current toast when showing new one', inject(function($rootElement) {
      setup({
        template: '<xng-toast class="one">'
      });
      expect($rootElement.find('xng-toast.one').length).toBe(1);
      expect($rootElement.find('xng-toast.two').length).toBe(0);
      expect($rootElement.find('xng-toast.three').length).toBe(0);

      setup({
        template: '<xng-toast class="two">'
      });
      expect($rootElement.find('xng-toast.one').length).toBe(0);
      expect($rootElement.find('xng-toast.two').length).toBe(1);
      expect($rootElement.find('xng-toast.three').length).toBe(0);

      setup({
        template: '<xng-toast class="three">'
      });
      expect($rootElement.find('xng-toast.one').length).toBe(0);
      expect($rootElement.find('xng-toast.two').length).toBe(0);
      expect($rootElement.find('xng-toast.three').length).toBe(1);
    }));

    it('should add class to toastParent', inject(function($rootElement) {
      setup({
        template: '<xng-toast>'
      });
      expect($rootElement.hasClass('xng-toast-open-bottom')).toBe(true);

      setup({
        template: '<xng-toast>',
        position: 'top'
      });
      expect($rootElement.hasClass('xng-toast-open-top')).toBe(true);
    }));
{'fraction_non_alphanumeric': 0.19709127382146438, 'fraction_numerical': 0.008692744901370779, 'mean_word_length': 3.2342533616418967, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '616092', 'n_tokens_mistral': 1947, 'n_tokens_neox': 1907, 'n_words': 267}