Sha256: 1d2d3e6c5290bf390d40e31d5871aaa7194b375ac5e3c3379bfcc712b0a6c84d

Contents?: true

Size: 1.77 KB

Versions: 2

Compression:

Stored size: 1.77 KB

Contents

import { ENV } from 'ember-environment';
import { camelize } from '@ember/string';
import { moduleFor, AbstractTestCase } from 'internal-test-helpers';

function test(assert, given, expected, description) {
  assert.deepEqual(camelize(given), expected, description);
  if (ENV.EXTEND_PROTOTYPES.String) {
    assert.deepEqual(given.camelize(), expected, description);
  }
}

moduleFor(
  'EmberStringUtils.camelize',
  class extends AbstractTestCase {
    ['@test String.prototype.camelize is not modified without EXTEND_PROTOTYPES'](assert) {
      if (!ENV.EXTEND_PROTOTYPES.String) {
        assert.ok(
          'undefined' === typeof String.prototype.camelize,
          'String.prototype helper disabled'
        );
      } else {
        assert.expect(0);
      }
    }

    ['@test String camelize tests'](assert) {
      test(assert, 'my favorite items', 'myFavoriteItems', 'camelize normal string');
      test(assert, 'I Love Ramen', 'iLoveRamen', 'camelize capitalized string');
      test(assert, 'css-class-name', 'cssClassName', 'camelize dasherized string');
      test(assert, 'action_name', 'actionName', 'camelize underscored string');
      test(assert, 'action.name', 'actionName', 'camelize dot notation string');
      test(assert, 'innerHTML', 'innerHTML', 'does nothing with camelcased string');
      test(
        assert,
        'PrivateDocs/OwnerInvoice',
        'privateDocs/ownerInvoice',
        'camelize namespaced classified string'
      );
      test(
        assert,
        'private_docs/owner_invoice',
        'privateDocs/ownerInvoice',
        'camelize namespaced underscored string'
      );
      test(
        assert,
        'private-docs/owner-invoice',
        'privateDocs/ownerInvoice',
        'camelize namespaced dasherized string'
      );
    }
  }
);

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
discourse-ember-source-3.5.1.1 dist/es/@ember/string/tests/camelize_test.js
discourse-ember-source-3.5.1.0 dist/dist/es/@ember/string/tests/camelize_test.js