Sha256: 1c842dd962db0b17b0c443e19b7a6c60812f870dc094d73497fb012c722ea627

Contents?: true

Size: 841 Bytes

Versions: 1

Compression:

Stored size: 841 Bytes

Contents

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

moduleFor(
  '@ember/-internals/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

1 entries across 1 versions & 1 rubygems

Version Path
discourse-ember-source-3.6.0.0 dist/es/@ember/-internals/utils/tests/to-string-test.js