Sha256: 04f207fc43219afd5de673f864c89028498a6cdaa19c5f63f5d9fce89541b2e7

Contents?: true

Size: 1.47 KB

Versions: 8

Compression:

Stored size: 1.47 KB

Contents

describe('inflector', function () {
  var inflectorFilter, testPhrase = 'here isMy_phone_number';

  beforeEach(module('ui.filters'));
  beforeEach(inject(function ($filter) {
    inflectorFilter = $filter('inflector');
  }));

  describe('default', function () {
    it('should default to humanize', function () {
      expect(inflectorFilter(testPhrase)).toEqual('Here Is My Phone Number');
    });
    it('should fail gracefully for invalid input', function () {
      expect(inflectorFilter(undefined)).toBeUndefined();
    });
    it('should do nothing for empty input', function () {
      expect(inflectorFilter('')).toEqual('');
    });
  });

  describe('humanize', function () {
    it('should uppercase first letter and separate words with a space', function () {
      expect(inflectorFilter(testPhrase, 'humanize')).toEqual('Here Is My Phone Number');
    });
  });
  describe('underscore', function () {
    it('should lowercase everything and separate words with an underscore', function () {
      expect(inflectorFilter(testPhrase, 'underscore')).toEqual('here_is_my_phone_number');
    });
  });
  describe('variable', function () {
    it('should remove all separators and camelHump the phrase', function () {
      expect(inflectorFilter(testPhrase, 'variable')).toEqual('hereIsMyPhoneNumber');
    });
    it('should do nothing if already formatted properly', function () {
      expect(inflectorFilter("hereIsMyPhoneNumber", 'variable')).toEqual('hereIsMyPhoneNumber');
    });
  });
});

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
active_record_survey_api-0.0.19 spec/test_app/vendor/assets/bower_components/angular-ui/modules/filters/inflector/test/inflectorSpec.js
active_record_survey_api-0.0.18 spec/test_app/vendor/assets/bower_components/angular-ui/modules/filters/inflector/test/inflectorSpec.js
active_record_survey_api-0.0.17 spec/test_app/vendor/assets/bower_components/angular-ui/modules/filters/inflector/test/inflectorSpec.js
active_record_survey_api-0.0.14 spec/test_app/vendor/assets/bower_components/angular-ui/modules/filters/inflector/test/inflectorSpec.js
active_record_survey_api-0.0.12 spec/test_app/vendor/assets/bower_components/angular-ui/modules/filters/inflector/test/inflectorSpec.js
active_record_survey_api-0.0.11 spec/test_app/vendor/assets/bower_components/angular-ui/modules/filters/inflector/test/inflectorSpec.js
active_record_survey_api-0.0.7 spec/test_app/vendor/assets/bower_components/angular-ui/modules/filters/inflector/test/inflectorSpec.js
active_record_survey_api-0.0.6 spec/test_app/vendor/assets/bower_components/angular-ui/modules/filters/inflector/test/inflectorSpec.js