Sha256: 629f906598798096a9528a3ef361b6e998eed9d9687fe0b8fbcc5aeca388eaba

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

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

2 entries across 2 versions & 1 rubygems

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