Sha256: 6d5e9f6509354889a4569cd6308cddeeeb4e48840f8965e648417c8a589d0607

Contents?: true

Size: 829 Bytes

Versions: 2

Compression:

Stored size: 829 Bytes

Contents

import { toString } from '..';
import { moduleFor, AbstractTestCase as TestCase } from 'internal-test-helpers';

moduleFor(
  'ember-utils toString',
  class extends TestCase {
    [`@test toString uses an object's toString method when available`](assert) {
      let obj = {
        toString() {
          return 'bob';
        },
      };

      assert.strictEqual(toString(obj), 'bob');
    }

    ['@test toString falls back to Object.prototype.toString'](assert) {
      let obj = Object.create(null);

      assert.strictEqual(toString(obj), {}.toString());
    }

    ['@test toString does not fail when called on Arrays with objects without toString method'](
      assert
    ) {
      let obj = Object.create(null);
      let arr = [obj, 2];

      assert.strictEqual(toString(arr), `${{}.toString()},2`);
    }
  }
);

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
discourse-ember-source-3.5.1.1 dist/es/ember-utils/tests/to-string-test.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember-utils/tests/to-string-test.js