mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 07:43:43 +08:00
c7475ee03b
* DEV: Import ember/object rather than Ember.Object globally * fixed broken object proxy import * prettier on js * added @ember/object/proxy to loader * added unstaged file * Fixed objet proxy reference is loader * Linting!
37 lines
937 B
JavaScript
37 lines
937 B
JavaScript
import EmberObject from "@ember/object";
|
|
import Model from "discourse/models/model";
|
|
|
|
QUnit.module("model:discourse");
|
|
|
|
QUnit.test(
|
|
"extractByKey: converts a list of hashes into a hash of instances of specified class, indexed by their ids",
|
|
assert => {
|
|
var firstObject = { id: "id_1", foo: "foo_1" };
|
|
var secondObject = { id: "id_2", foo: "foo_2" };
|
|
|
|
var actual = Model.extractByKey([firstObject, secondObject], EmberObject);
|
|
var expected = {
|
|
id_1: EmberObject.create(firstObject),
|
|
id_2: EmberObject.create(secondObject)
|
|
};
|
|
|
|
assert.ok(_.isEqual(actual, expected));
|
|
}
|
|
);
|
|
|
|
QUnit.test(
|
|
"extractByKey: returns an empty hash if there isn't anything to convert",
|
|
assert => {
|
|
assert.deepEqual(
|
|
Model.extractByKey(),
|
|
{},
|
|
"when called without parameters"
|
|
);
|
|
assert.deepEqual(
|
|
Model.extractByKey([]),
|
|
{},
|
|
"when called with an empty array"
|
|
);
|
|
}
|
|
);
|