<commit_before>define ['ngmocks', 'helpers', 'moment'], (mocks, helpers, moment) ->
  describe 'Unit Testing Helpers', ->
    describe 'ObjectHelper', ->
      ObjectHelper = null

      beforeEach ->
        # Obtain the Helpers service.
        angular.mock.module('qiprofile.helpers')
        inject ['ObjectHelper', (_ObjectHelper_) ->
          ObjectHelper = _ObjectHelper_
        ]

      describe 'copyNonNullPublicProperties', ->
        it 'should copy public properties', ->
          src = {a: 1}
          dest = {}
          ObjectHelper.copyNonNullPublicProperties(src, dest)
          expect(dest.a, 'A public property was not copied').to.equal(src.a)

        it 'should replace null public properties', ->
          src = {a: 1}
          dest = {a: null}
          ObjectHelper.copyNonNullPublicProperties(src, dest)
          expect(dest.a, 'A public property was not copied').to.equal(src.a)

        it 'should not copy private properties', ->
          src = {_a: 2}
          dest = {}
          ObjectHelper.copyNonNullPublicProperties(src, dest)
          expect(dest._a, 'A private property was copied').to.not.exist

        it 'should not overwrite non-null properties', ->
          src = {a: 1}
          dest = {a: 2}
          ObjectHelper.copyNonNullPublicProperties(src, dest)
          expect(dest.a, 'A non-null destination property was overrwritten')
            .to.not.equal(src.a)

    describe 'DateHelper', ->
      DateHelper = null

      beforeEach ->
        # Obtain the Helpers service.
        angular.mock.module('qiprofile.helpers')
        inject ['DateHelper', (_DateHelper_) ->
          DateHelper = _DateHelper_
        ]

      describe 'asMoment', ->
        it 'should parse a string date', ->
          dateStr = 'Aug 14, 2012'
          expected = moment(dateStr)
          actual = DateHelper.asMoment(dateStr)
          expect(actual, 'A string date was not parsed').to.eql(expected)

        it 'should parse an integer date', ->
          dateInt = moment().valueOf()
          actual = DateHelper.asMoment(dateInt)
          expect(actual.valueOf(), 'An integer date was not parsed').to.eql(dateInt)
<commit_msg>Add aliasProperty test cases.<commit_after>define ['ngmocks', 'helpers', 'moment'], (mocks, helpers, moment) ->
  describe 'Unit Testing Helpers', ->
    describe 'ObjectHelper', ->
      ObjectHelper = null

      beforeEach ->
        # Obtain the ObjectHelper service.
        angular.mock.module('qiprofile.helpers')
        inject ['ObjectHelper', (_ObjectHelper_) ->
          ObjectHelper = _ObjectHelper_
        ]
      
      describe 'fromJSON', ->
        mock =
          _id: 1
          an_int: 1
          inner:
            an_obj:
              an_int: 3
        obj = null
        
        beforeEach ->
          data = JSON.stringify(mock)
          obj = ObjectHelper.fromJson(data)
        
        it 'should add camelCase aliases to underscore properties', ->
          expect('anInt' in Object.keys(obj), "the alias is not defined as an enumerable property")
            .to.be.true
          expect(obj.anInt, "the alias value is incorrect").to.equal(mock.an_int)
          obj.an_int = obj.an_int + 1
          expect(obj.anInt, "the alias value does not reflect an underscore change")
            .to.equal(obj.an_int)
          obj.anInt = obj.anInt + 1
          expect(obj.an_int, "the underscore value does not reflect an alias change")
            .to.equal(obj.anInt)

        it 'should make the camelCase alias enumerable', ->
          expect('anInt' in Object.keys(obj), "the underscore property is still enumerable")
            .to.be.true   

        it 'should make the underscore property non-enumerable', ->
          expect('an_int' in Object.keys(obj), "the underscore property is still enumerable")
            .to.be.false   

        it 'should make the underscore property nonenumerable', ->
          expect(obj.an_int, "an_int is incorrect").to.equal(mock.an_int)   

        it 'should add camelCase aliases to inner objects', ->
          expect('anObj' in Object.keys(obj.inner), "the inner underscore property is not aliased")
            .to.be.true
          expect(obj.inner.anObj.anInt, "the inner reference alias value is incorrect")
            .to.eql(mock.inner.an_obj.an_int)

      describe 'aliasPublicDataProperties', ->
        it 'should alias public value properties', ->
          src = {a: 1}
          dest = {}
          ObjectHelper.aliasPublicDataProperties(src, dest)
          expect(dest.a, 'The public value property was not aliased').to.equal(src.a)

        it 'should alias public virtual properties', ->
          src = {a: 1}
          Object.defineProperty src, 'b',
            enumerable: true
            get: -> src.a
          dest = {}
          ObjectHelper.aliasPublicDataProperties(src, dest)
          expect(dest.b, 'The public virtual property was not aliased').to.equal(src.b)

        it 'should alias non-eumerable public properties', ->
          src = {}
          Object.defineProperty src, 'a',
            enumerable: false
            value: 1
          dest = {}
          ObjectHelper.aliasPublicDataProperties(src, dest)
          expect(dest.a, 'The public virtual property was not aliased').to.equal(src.a)

        it 'should not alias private properties', ->
          src = {_a: 2}
          dest = {}
          ObjectHelper.aliasPublicDataProperties(src, dest)
          expect(dest._a, 'A private property was aliased').to.not.exist

        it 'should not alias existing properties', ->
          src = {a: 1}
          dest = {a: null}
          ObjectHelper.aliasPublicDataProperties(src, dest)
          expect(dest.a, 'A non-null destination property was overrwritten')
            .to.not.equal(src.a)

    describe 'DateHelper', ->
      DateHelper = null

      beforeEach ->
        # Obtain the DateHelper service.
        angular.mock.module('qiprofile.helpers')
        inject ['DateHelper', (_DateHelper_) ->
          DateHelper = _DateHelper_
        ]

      describe 'asMoment', ->
        it 'should parse a string date', ->
          dateStr = 'Aug 14, 2012'
          expected = moment(dateStr)
          actual = DateHelper.asMoment(dateStr)
          expect(actual, 'A string date was not parsed').to.eql(expected)

        it 'should parse an integer date', ->
          dateInt = moment().valueOf()
          actual = DateHelper.asMoment(dateInt)
          expect(actual.valueOf(), 'An integer date was not parsed').to.eql(dateInt)

{'fraction_non_alphanumeric': 0.10907704042715484, 'fraction_numerical': 0.004118993135011442, 'mean_word_length': 2.0692883895131087, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 44, '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': '4598987', 'n_tokens_mistral': 1834, 'n_tokens_neox': 1783, 'n_words': 506}