<commit_before>'use strict';

const m = require('mochainon');
const fs = require('fs');
const path = require('path');
const angular = require('angular');
require('angular-mocks');

describe('Browser: SVGIcon', function() {

  beforeEach(angular.mock.module(
    require('../../../lib/browser/components/svg-icon/svg-icon')
  ));

  describe('svgIcon', function() {

    let $compile;
    let $rootScope;

    beforeEach(angular.mock.inject(function(_$compile_, _$rootScope_, $templateCache) {
      $compile = _$compile_;
      $rootScope = _$rootScope_;

      // Workaround `Unexpected request: GET template.html. No more request expected` error.
      // See http://stackoverflow.com/a/29437480/1641422
      const templatePath = './browser/components/svg-icon/templates/svg-icon.tpl.html';
      const template = fs.readFileSync(path.resolve('lib', templatePath), {
        encoding: 'utf8'
      });
      $templateCache.put(templatePath, template);

    }));

    it('should inline the svg contents in the element', function() {
      const icon = "../../../../../assets/images/etcher.svg";
      let iconContents = fs.readFileSync(path.join(__dirname, '../../../assets/images/etcher.svg'), {
        encoding: 'utf8'
      }).split('\n');

      // Injecting XML as HTML causes the XML header to be commented out.
      // Modify here to ease assertions later on.
      iconContents[0] = '<!--' + iconContents[0].slice(1, iconContents[0].length - 1) + '-->';
      iconContents = iconContents.join('\n');

      const element = $compile(`<svg-icon path="${icon}">Resin.io</svg-icon>`)($rootScope);
      $rootScope.$digest();
      m.chai.expect(element.html()).to.equal(iconContents);
    });

    it('should default the size to 40x40 pixels', function() {
      const icon = "../../../../../assets/images/etcher.svg";
      const element = $compile(`<svg-icon path="${icon}">Resin.io</svg-icon>`)($rootScope);
      $rootScope.$digest();
      m.chai.expect(element.css('width')).to.equal('40px');
      m.chai.expect(element.css('height')).to.equal('40px');
    });

    it('should be able to set a custom height', function() {
      const icon = "../../../../../assets/images/etcher.svg";
      const element = $compile(`<svg-icon path="${icon}" width="20px">Resin.io</svg-icon>`)($rootScope);
      $rootScope.$digest();
      m.chai.expect(element.css('width')).to.equal('20px');
      m.chai.expect(element.css('height')).to.equal('40px');
    });

    it('should be able to set a custom height', function() {
      const icon = "../../../../../assets/images/etcher.svg";
      const element = $compile(`<svg-icon path="${icon}" height="20px">Resin.io</svg-icon>`)($rootScope);
      $rootScope.$digest();
      m.chai.expect(element.css('width')).to.equal('40px');
      m.chai.expect(element.css('height')).to.equal('20px');<commit_msg>Fix double-quote lint warnings (#329)<commit_after>'use strict';

const m = require('mochainon');
const fs = require('fs');
const path = require('path');
const angular = require('angular');
require('angular-mocks');

describe('Browser: SVGIcon', function() {

  beforeEach(angular.mock.module(
    require('../../../lib/browser/components/svg-icon/svg-icon')
  ));

  describe('svgIcon', function() {

    let $compile;
    let $rootScope;

    beforeEach(angular.mock.inject(function(_$compile_, _$rootScope_, $templateCache) {
      $compile = _$compile_;
      $rootScope = _$rootScope_;

      // Workaround `Unexpected request: GET template.html. No more request expected` error.
      // See http://stackoverflow.com/a/29437480/1641422
      const templatePath = './browser/components/svg-icon/templates/svg-icon.tpl.html';
      const template = fs.readFileSync(path.resolve('lib', templatePath), {
        encoding: 'utf8'
      });
      $templateCache.put(templatePath, template);

    }));

    it('should inline the svg contents in the element', function() {
      const icon = '../../../../../assets/images/etcher.svg';
      let iconContents = fs.readFileSync(path.join(__dirname, '../../../assets/images/etcher.svg'), {
        encoding: 'utf8'
      }).split('\n');

      // Injecting XML as HTML causes the XML header to be commented out.
      // Modify here to ease assertions later on.
      iconContents[0] = '<!--' + iconContents[0].slice(1, iconContents[0].length - 1) + '-->';
      iconContents = iconContents.join('\n');

      const element = $compile(`<svg-icon path="${icon}">Resin.io</svg-icon>`)($rootScope);
      $rootScope.$digest();
      m.chai.expect(element.html()).to.equal(iconContents);
    });

    it('should default the size to 40x40 pixels', function() {
      const icon = '../../../../../assets/images/etcher.svg';
      const element = $compile(`<svg-icon path="${icon}">Resin.io</svg-icon>`)($rootScope);
      $rootScope.$digest();
      m.chai.expect(element.css('width')).to.equal('40px');
      m.chai.expect(element.css('height')).to.equal('40px');
    });

    it('should be able to set a custom height', function() {
      const icon = '../../../../../assets/images/etcher.svg';
      const element = $compile(`<svg-icon path="${icon}" width="20px">Resin.io</svg-icon>`)($rootScope);
      $rootScope.$digest();
      m.chai.expect(element.css('width')).to.equal('20px');
      m.chai.expect(element.css('height')).to.equal('40px');
    });

    it('should be able to set a custom height', function() {
      const icon = '../../../../../assets/images/etcher.svg';
      const element = $compile(`<svg-icon path="${icon}" height="20px">Resin.io</svg-icon>`)($rootScope);
      $rootScope.$digest();
      m.chai.expect(element.css('width')).to.equal('40px');
      m.chai.expect(element.css('height')).to.equal('20px');
{'fraction_non_alphanumeric': 0.20810055865921787, 'fraction_numerical': 0.01518854748603352, 'mean_word_length': 3.1215827338129496, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '3942106', 'n_tokens_mistral': 1821, 'n_tokens_neox': 1768, 'n_words': 331}