<commit_before>'use strict';

import { expect } from 'chai';

import '../../src/Extensions/String';

describe('String Extensions', () => {
  describe('String.IsNullOrEmpty', () => {
    it('Returns true when a string is undefined', () => {
      let str: string;
      expect(String.isNullOrEmpty(str)).to.equal(true);
    });

    it('Returns true when a string is null', () => {
      let str: string = null;
      expect(String.isNullOrEmpty(str)).to.equal(true);
    });

    it('Returns true when a string is empty', () => {
      let str: string = '';
      expect(String.isNullOrEmpty(str)).to.equal(true);
    });

    it('Returns true when a string is empty', () => {
      let str: string = '';
      expect(String.isNullOrEmpty(str)).to.equal(true);
    });

    it('Returns false when a string is non-empty', () => {
      let str: string = 'asdf';
      expect(String.isNullOrEmpty(str)).to.equal(false);
    });
  });

  describe('String.stringify', () => {
    it('Can handle a null value', () => {
      let val: any = null;
      expect(String.stringify(val)).to.equal(null);
    });

    it('Can stringify an empty object', () => {
      let val: any = {};
      expect(String.stringify(val)).to.equal(JSON.stringify(val, null, 2));
    });

    it('Can stringify a non-empty object', () => {
      let val: any = { text: 'test' };
      expect(String.stringify(val)).to.equal(JSON.stringify(val, null, 2));
    });

    it('Can stringify with custom spaces', () => {
      let val: any = { text: 'test' };
      expect(String.stringify(val, null, 4)).to.equal(JSON.stringify(val, null, 4));
    });

    it('Can stringify an object with an overridden toString() function', () => {
      class Test {
        public text = 'test';

        toString() {
          return this.text;
        }
      }

      let val = new Test();
      expect(String.stringify(val)).to.equal('test');
    });

    it('Can stringify an object with an overridden toString() function in a base class', () => {
      class Base {
        public text = 'test';

        toString() {
          return this.text;
        }
      }
      class Test extends Base {
      }

      let val = new Test();
      expect(String.stringify(val)).to.equal('test');
    });
  });

  describe('String.Format', () => {
    it('Can format an undefined string', () => {
      let format: string;
      let result = String.format(format);
      expect(result).to.equal(format);
    });

    it('Can format a null string', () => {
      let format: string = null;
      let result = String.format(format);
      expect(result).to.equal(format);
    });

    it('Can format an empty string', () => {
      let format: string = '';
      let result = String.format(format);
      expect(result).to.equal(format);
    });

    it('Can format a string with no placeholders and no args', () => {
      let format: string = 'asdf';
      let result = String.format(format);
      expect(result).to.equal(format);
    });

    it('Can format a string with no placeholders and unused args', () => {
      let format: string = 'asdf';
      let result = String.format(format, 123);
      expect(result).to.equal(format);
    });

    it('Can format a string with placeholders and matching args', () => {
      let format: string = 'asdf {0}';
      let result = String.format(format, 123);
      expect(result).to.equal('asdf 123');
    });

    it('Can format a string with placeholders and extra args', () => {
      let format: string = 'asdf {0}';
      let result = String.format(format, 123, 456);
      expect(result).to.equal('asdf 123');
    });

    it('Can format a string with placeholders and multiple args', () => {
      let format: string = 'asdf {0} {1}';
      let result = String.format(format, 123, 456);
      expect(result).to.equal('asdf 123 456');
    });

    it('Can format a string with multiple placeholders per arg', () => {
      let format: string = 'asdf {0} {1} {0}';
      let result = String.format(format, 123, 456);
      expect(result).to.equal('asdf 123 456 123');
    });
  });
});<commit_msg>removing old String.format tests that are no longer valid<commit_after>'use strict';

import { expect } from 'chai';

import '../../src/Extensions/String';

describe('String Extensions', () => {
  describe('String.IsNullOrEmpty', () => {
    it('Returns true when a string is undefined', () => {
      let str: string;
      expect(String.isNullOrEmpty(str)).to.equal(true);
    });

    it('Returns true when a string is null', () => {
      let str: string = null;
      expect(String.isNullOrEmpty(str)).to.equal(true);
    });

    it('Returns true when a string is empty', () => {
      let str: string = '';
      expect(String.isNullOrEmpty(str)).to.equal(true);
    });

    it('Returns true when a string is empty', () => {
      let str: string = '';
      expect(String.isNullOrEmpty(str)).to.equal(true);
    });

    it('Returns false when a string is non-empty', () => {
      let str: string = 'asdf';
      expect(String.isNullOrEmpty(str)).to.equal(false);
    });
  });

  describe('String.stringify', () => {
    it('Can handle a null value', () => {
      let val: any = null;
      expect(String.stringify(val)).to.equal(null);
    });

    it('Can stringify an empty object', () => {
      let val: any = {};
      expect(String.stringify(val)).to.equal(JSON.stringify(val, null, 2));
    });

    it('Can stringify a non-empty object', () => {
      let val: any = { text: 'test' };
      expect(String.stringify(val)).to.equal(JSON.stringify(val, null, 2));
    });

    it('Can stringify with custom spaces', () => {
      let val: any = { text: 'test' };
      expect(String.stringify(val, null, 4)).to.equal(JSON.stringify(val, null, 4));
    });

    it('Can stringify an object with an overridden toString() function', () => {
      class Test {
        public text = 'test';

        toString() {
          return this.text;
        }
      }

      let val = new Test();
      expect(String.stringify(val)).to.equal('test');
    });

    it('Can stringify an object with an overridden toString() function in a base class', () => {
      class Base {
        public text = 'test';

        toString() {
          return this.text;
        }
      }
      class Test extends Base {
      }

      let val = new Test();
      expect(String.stringify(val)).to.equal('test');
    });
  });
});
{'fraction_non_alphanumeric': 0.17360137135733208, 'fraction_numerical': 0.009350163627863487, 'mean_word_length': 2.532195927352779, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 41, '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': '6783336', 'n_tokens_mistral': 2005, 'n_tokens_neox': 1916, 'n_words': 512}