Skip to content

Commit

Permalink
cp deps and service serialization keys test
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeart committed Apr 18, 2018
1 parent 3910f49 commit 2306bbe
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ember_debug/object-inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,8 @@ function addProperties(properties, hash) {
}
let options = { isMandatorySetter: isMandatorySetter(hash, prop) };

if (typeof hash[prop] === 'object' && hash[prop] !== null) {
options.isService = hash[prop].type === 'service';
if (typeof hash[prop] === 'object' && hash[prop] !== null && hash[prop].constructor) {
options.isService = hash[prop].constructor.isServiceFactory;
}

if (isComputed(hash[prop])) {
Expand Down
39 changes: 39 additions & 0 deletions tests/ember_debug/object-inspector-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Component from '@ember/component';
import { run } from '@ember/runloop';
import { guidFor } from '@ember/object/internals';
import EmberObject, { computed } from '@ember/object';
import Service from '@ember/service';
import Ember from 'ember';
import { module, test } from 'qunit';
import { settings as nativeDomHelpersSettings } from 'ember-native-dom-helpers';
Expand Down Expand Up @@ -368,6 +369,44 @@ module('Ember Debug - Object Inspector', function(hooks) {
assert.ok(message.details[4].name !== 'MixinToSkip', 'Correctly skips properties');
});


test("Service should be successfully tagged as service on serialization", function(assert) {
let inspectedService = Service.extend({
fooBoo() {
return true;
}
}).create();

let inspected = EmberObject.extend({
service: inspectedService
}).create();

objectInspector.sendObject(inspected);

let serializedServiceProperty = message.details[1].properties[0];

assert.equal(serializedServiceProperty.isService, true);
});

test("Computed property dependent keys and code should be successfully serialized", function(assert) {
let compuedFn = function() {
return this.get("foo") + this.get("bar");
};

let inspected = EmberObject.extend({
foo: true,
bar: false,
fooAndBar: computed("foo", "bar", compuedFn)
}).create();

objectInspector.sendObject(inspected);
let serializedComputedProperty = message.details[1].properties[2];

assert.equal(serializedComputedProperty.code, compuedFn.toString());
assert.equal(serializedComputedProperty.dependentKeys[0], "foo");
assert.equal(serializedComputedProperty.dependentKeys[1], "bar");
});

test('Read Only Computed properties mush have a readOnly property', function(assert) {
let inspected = EmberObject.extend({
readCP: computed(function() {}).property().readOnly(),
Expand Down

0 comments on commit 2306bbe

Please sign in to comment.