Sha256: 2187af01d85c79a6ba1a4ef94476d796a1bf0dc2bce0b1683741cb0d2948854e

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

import { ENV } from '@ember/-internals/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

1 entries across 1 versions & 1 rubygems

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