We used many global functions to handle tests when they should be imported like other libraries in our application. This also gets us closer to the way Ember CLI prefers our tests to be laid out.
52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
import { test, module } from "qunit";
|
|
import EmberObject from "@ember/object";
|
|
import Setting from "admin/mixins/setting-object";
|
|
|
|
module("mixin:setting-object");
|
|
|
|
test("flat array", (assert) => {
|
|
const FooSetting = EmberObject.extend(Setting);
|
|
|
|
const fooSettingInstance = FooSetting.create({
|
|
valid_values: ["foo", "bar"],
|
|
});
|
|
|
|
assert.equal(fooSettingInstance.computedValueProperty, null);
|
|
assert.equal(fooSettingInstance.computedNameProperty, null);
|
|
});
|
|
|
|
test("object", (assert) => {
|
|
const FooSetting = EmberObject.extend(Setting);
|
|
|
|
const fooSettingInstance = FooSetting.create({
|
|
valid_values: [{ value: "foo", name: "bar" }],
|
|
});
|
|
|
|
assert.equal(fooSettingInstance.computedValueProperty, "value");
|
|
assert.equal(fooSettingInstance.computedNameProperty, "name");
|
|
});
|
|
|
|
test("no values", (assert) => {
|
|
const FooSetting = EmberObject.extend(Setting);
|
|
|
|
const fooSettingInstance = FooSetting.create({
|
|
valid_values: [],
|
|
});
|
|
|
|
assert.equal(fooSettingInstance.computedValueProperty, null);
|
|
assert.equal(fooSettingInstance.computedNameProperty, null);
|
|
});
|
|
|
|
test("value/name properties defined", (assert) => {
|
|
const FooSetting = EmberObject.extend(Setting);
|
|
|
|
const fooSettingInstance = FooSetting.create({
|
|
valueProperty: "foo",
|
|
nameProperty: "bar",
|
|
valid_values: [],
|
|
});
|
|
|
|
assert.equal(fooSettingInstance.computedValueProperty, "foo");
|
|
assert.equal(fooSettingInstance.computedNameProperty, "bar");
|
|
});
|