Skip to content

Commit

Permalink
Merge pull request #16036 from thoov/ember-metal-test-2
Browse files Browse the repository at this point in the history
[CLEANUP] Convert ember-metal accessors tests to new style
  • Loading branch information
rwjblue authored Dec 30, 2017
2 parents b6d4618 + b2f6c81 commit 16f30b8
Show file tree
Hide file tree
Showing 7 changed files with 671 additions and 616 deletions.
83 changes: 42 additions & 41 deletions packages/ember-metal/tests/accessors/get_path_test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { get } from '../..';
import { moduleFor, AbstractTestCase } from 'internal-test-helpers';

let obj;
const moduleOpts = {
setup() {

moduleFor('Ember.get with path', class extends AbstractTestCase {
constructor() {
super();
obj = {
foo: {
bar: {
Expand All @@ -21,59 +24,57 @@ const moduleOpts = {
},
nullValue: null
};
},
}

teardown() {
obj = undefined;
}
};

QUnit.module('Ember.get with path', moduleOpts);

// ..........................................................
// LOCAL PATHS
//
// ..........................................................
// LOCAL PATHS
//
['@test [obj, foo] -> obj.foo'](assert) {
assert.deepEqual(get(obj, 'foo'), obj.foo);
}

QUnit.test('[obj, foo] -> obj.foo', function() {
deepEqual(get(obj, 'foo'), obj.foo);
});
['@test [obj, foo.bar] -> obj.foo.bar'](assert) {
assert.deepEqual(get(obj, 'foo.bar'), obj.foo.bar);
}

QUnit.test('[obj, foo.bar] -> obj.foo.bar', function() {
deepEqual(get(obj, 'foo.bar'), obj.foo.bar);
});
['@test [obj, foothis.bar] -> obj.foothis.bar'](assert) {
assert.deepEqual(get(obj, 'foothis.bar'), obj.foothis.bar);
}

QUnit.test('[obj, foothis.bar] -> obj.foothis.bar', function() {
deepEqual(get(obj, 'foothis.bar'), obj.foothis.bar);
});
['@test [obj, falseValue.notDefined] -> (undefined)'](assert) {
assert.strictEqual(get(obj, 'falseValue.notDefined'), undefined);
}

QUnit.test('[obj, falseValue.notDefined] -> (undefined)', function() {
strictEqual(get(obj, 'falseValue.notDefined'), undefined);
});
['@test [obj, emptyString.length] -> 0'](assert) {
assert.strictEqual(get(obj, 'emptyString.length'), 0);
}

QUnit.test('[obj, emptyString.length] -> 0', function() {
strictEqual(get(obj, 'emptyString.length'), 0);
});
['@test [obj, nullValue.notDefined] -> (undefined)'](assert) {
assert.strictEqual(get(obj, 'nullValue.notDefined'), undefined);
}

QUnit.test('[obj, nullValue.notDefined] -> (undefined)', function() {
strictEqual(get(obj, 'nullValue.notDefined'), undefined);
});
// ..........................................................
// GLOBAL PATHS TREATED LOCAL WITH GET
//

// ..........................................................
// GLOBAL PATHS TREATED LOCAL WITH GET
//
['@test [obj, Wuz] -> obj.Wuz'](assert) {
assert.deepEqual(get(obj, 'Wuz'), obj.Wuz);
}

QUnit.test('[obj, Wuz] -> obj.Wuz', function() {
deepEqual(get(obj, 'Wuz'), obj.Wuz);
});
['@test [obj, Wuz.nar] -> obj.Wuz.nar'](assert) {
assert.deepEqual(get(obj, 'Wuz.nar'), obj.Wuz.nar);
}

QUnit.test('[obj, Wuz.nar] -> obj.Wuz.nar', function() {
deepEqual(get(obj, 'Wuz.nar'), obj.Wuz.nar);
});
['@test [obj, Foo] -> (undefined)'](assert) {
assert.strictEqual(get(obj, 'Foo'), undefined);
}

QUnit.test('[obj, Foo] -> (undefined)', function() {
strictEqual(get(obj, 'Foo'), undefined);
['@test [obj, Foo.bar] -> (undefined)'](assert) {
assert.strictEqual(get(obj, 'Foo.bar'), undefined);
}
});

QUnit.test('[obj, Foo.bar] -> (undefined)', function() {
strictEqual(get(obj, 'Foo.bar'), undefined);
});
32 changes: 17 additions & 15 deletions packages/ember-metal/tests/accessors/get_properties_test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import { getProperties } from '../..';
import { moduleFor, AbstractTestCase } from 'internal-test-helpers';

QUnit.module('Ember.getProperties');
moduleFor('Ember.getProperties', class extends AbstractTestCase {
['@test can retrieve a hash of properties from an object via an argument list or array of property names'](assert) {
let obj = {
firstName: 'Steve',
lastName: 'Jobs',
companyName: 'Apple, Inc.'
};

QUnit.test('can retrieve a hash of properties from an object via an argument list or array of property names', function() {
let obj = {
firstName: 'Steve',
lastName: 'Jobs',
companyName: 'Apple, Inc.'
};

deepEqual(getProperties(obj, 'firstName', 'lastName'), { firstName: 'Steve', lastName: 'Jobs' });
deepEqual(getProperties(obj, 'firstName', 'lastName'), { firstName: 'Steve', lastName: 'Jobs' });
deepEqual(getProperties(obj, 'lastName'), { lastName: 'Jobs' });
deepEqual(getProperties(obj), {});
deepEqual(getProperties(obj, ['firstName', 'lastName']), { firstName: 'Steve', lastName: 'Jobs' });
deepEqual(getProperties(obj, ['firstName']), { firstName: 'Steve' });
deepEqual(getProperties(obj, []), {});
assert.deepEqual(getProperties(obj, 'firstName', 'lastName'), { firstName: 'Steve', lastName: 'Jobs' });
assert.deepEqual(getProperties(obj, 'firstName', 'lastName'), { firstName: 'Steve', lastName: 'Jobs' });
assert.deepEqual(getProperties(obj, 'lastName'), { lastName: 'Jobs' });
assert.deepEqual(getProperties(obj), {});
assert.deepEqual(getProperties(obj, ['firstName', 'lastName']), { firstName: 'Steve', lastName: 'Jobs' });
assert.deepEqual(getProperties(obj, ['firstName']), { firstName: 'Steve' });
assert.deepEqual(getProperties(obj, []), {});
}
});

Loading

0 comments on commit 16f30b8

Please sign in to comment.