Skip to content

Commit

Permalink
added tests for get with paths
Browse files Browse the repository at this point in the history
  • Loading branch information
bekzod committed Oct 5, 2017
1 parent e4d724a commit 21f4054
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/ember-metal/tests/accessors/get_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import {
observer,
addObserver
} from '../..';
import { run } from 'ember-metal';
import {
Object as EmberObject
} from 'ember-runtime';

QUnit.module('Ember.get');

Expand Down Expand Up @@ -85,6 +89,23 @@ QUnit.test('warn on attempts to get a property path of undefined', function() {
}, /Cannot call get with 'aProperty.on.aPath' on an undefined object/);
});

QUnit.test("get works with paths correctly", function() {
let func = function() {};
func.bar = 'awesome';

let obj = EmberObject.create({ bar: 'great' });
run(() => obj.destroy())

equal(get({ foo: null }, 'foo.bar'), undefined);
equal(get({ foo: { bar: 'hello' } }, 'foo.bar.length'), 5);
equal(get({ foo: func }, 'foo.bar'), 'awesome');
equal(get({ foo: func }, 'foo.bar.length'), 7);
equal(get({}, 'foo.bar.length'), undefined);
equal(get(function(){}, 'foo.bar.length'), undefined);
equal(get('', 'foo.bar.length'), undefined);
equal(get({ foo: obj }, 'foo.bar'), undefined);
});

QUnit.test('warn on attempts to get a property of null', function() {
expectAssertion(function() {
get(null, 'aProperty');
Expand Down

0 comments on commit 21f4054

Please sign in to comment.