Sha256: b384e1d310acb53c000085be1c4f98fd11b2cc0e3c2c4352098e0c0b0ffcc951

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

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

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

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

    ['@test String w tests'](assert) {
      test(
        assert,
        'one two three',
        ['one', 'two', 'three'],
        `w('one two three') => ['one','two','three']`
      );
      test(
        assert,
        'one   two  three',
        ['one', 'two', 'three'],
        `w('one    two    three') with extra spaces between words => ['one','two','three']`
      );
      test(assert, 'one\ttwo  three', ['one', 'two', 'three'], `w('one two three') with tabs`);
    }
  }
);

Version data entries

1 entries across 1 versions & 1 rubygems

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