Sha256: 437dc895d9e76e6f0975f81bada8dd879d852a40cdb40f11d989f95f610a7816

Contents?: true

Size: 831 Bytes

Versions: 2

Compression:

Stored size: 831 Bytes

Contents

import { get, set } from 'ember-metal';
import { AbstractTestCase } from 'internal-test-helpers';
import { runArrayTests } from '../helpers/array';

class FirstObjectTests extends AbstractTestCase {
  '@test returns first item in enumerable'() {
    let obj = this.newObject();
    this.assert.equal(get(obj, 'firstObject'), this.toArray(obj)[0]);
  }

  '@test returns undefined if enumerable is empty'() {
    let obj = this.newObject([]);
    this.assert.equal(get(obj, 'firstObject'), undefined);
  }

  '@test can not be set'() {
    let obj = this.newObject([]);

    this.assert.equal(get(obj, 'firstObject'), this.toArray(obj)[0]);

    this.assert.throws(() => {
      set(obj, 'firstObject', 'foo!');
    }, /Cannot set read-only property "firstObject" on object/);
  }
}

runArrayTests('firstObject', FirstObjectTests);

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
discourse-ember-source-3.5.1.1 dist/es/ember-runtime/tests/array/firstObject-test.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember-runtime/tests/array/firstObject-test.js