Sha256: 826e32a233e08811c0e7f1a2357fef897111951cc6956f74f5e998218ba378c1

Contents?: true

Size: 1.52 KB

Versions: 2

Compression:

Stored size: 1.52 KB

Contents

import copy from '../../lib/copy';
import { moduleFor, AbstractTestCase } from 'internal-test-helpers';

moduleFor(
  'Ember Copy Method',
  class extends AbstractTestCase {
    ['@test Ember.copy null'](assert) {
      let obj = { field: null };
      let copied = null;
      expectDeprecation(() => {
        copied = copy(obj, true);
      }, 'Use ember-copy addon instead of copy method and Copyable mixin.');
      assert.equal(copied.field, null, 'null should still be null');
    }

    ['@test Ember.copy date'](assert) {
      let date = new Date(2014, 7, 22);
      let dateCopy = null;
      expectDeprecation(() => {
        dateCopy = copy(date);
      }, 'Use ember-copy addon instead of copy method and Copyable mixin.');
      assert.equal(date.getTime(), dateCopy.getTime(), 'dates should be equivalent');
    }

    ['@test Ember.copy null prototype object'](assert) {
      let obj = Object.create(null);

      obj.foo = 'bar';
      let copied = null;
      expectDeprecation(() => {
        copied = copy(obj);
      }, 'Use ember-copy addon instead of copy method and Copyable mixin.');

      assert.equal(copied.foo, 'bar', 'bar should still be bar');
    }

    ['@test Ember.copy Array'](assert) {
      let array = [1, null, new Date(2015, 9, 9), 'four'];
      let arrayCopy = null;
      expectDeprecation(() => {
        arrayCopy = copy(array);
      }, 'Use ember-copy addon instead of copy method and Copyable mixin.');

      assert.deepEqual(array, arrayCopy, 'array content cloned successfully in new array');
    }
  }
);

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
discourse-ember-source-3.5.1.1 dist/es/ember-runtime/tests/core/copy_test.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember-runtime/tests/core/copy_test.js