Sha256: 921e843c795b90d09fee86e657ad7d5d176b920108464d7e3ad7c958c470f38c

Contents?: true

Size: 1.66 KB

Versions: 2

Compression:

Stored size: 1.66 KB

Contents

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

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

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

    ['@test String decamelize tests'](assert) {
      test(assert, 'my favorite items', 'my favorite items', 'does nothing with normal string');
      test(assert, 'css-class-name', 'css-class-name', 'does nothing with dasherized string');
      test(assert, 'action_name', 'action_name', 'does nothing with underscored string');
      test(
        assert,
        'innerHTML',
        'inner_html',
        'converts a camelized string into all lower case separated by underscores.'
      );
      test(assert, 'size160Url', 'size160_url', 'decamelizes strings with numbers');
      test(
        assert,
        'PrivateDocs/OwnerInvoice',
        'private_docs/owner_invoice',
        'decamelize namespaced classified string'
      );
      test(
        assert,
        'privateDocs/ownerInvoice',
        'private_docs/owner_invoice',
        'decamelize namespaced camelized 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/decamelize_test.js
discourse-ember-source-3.5.1.0 dist/dist/es/@ember/string/tests/decamelize_test.js