discourse/test/javascripts/models/model-test.js.es6
Sam Saffron d0c5205a52 Feature: Change markdown engine to markdown it
This commit removes the old evilstreak markdownjs engine.

- Adds specs to WhiteLister and changes it to stop using globals
    (Fixes large memory leak)
- Fixes edge cases around bbcode handling
- Removes mdtest which is no longer valid (to be replaced with
    CommonMark)
- Updates MiniRacer to correct minor unmanaged memory leak
- Fixes plugin specs
2017-07-17 11:41:34 -04:00

22 lines
811 B
JavaScript

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], Ember.Object);
var expected = {
id_1: Ember.Object.create(firstObject),
id_2: Ember.Object.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");
});