2016-08-26 01:14:56 +08:00
|
|
|
import WizardField from "wizard/models/wizard-field";
|
2020-10-07 00:54:05 +08:00
|
|
|
import { moduleFor } from "ember-qunit";
|
|
|
|
import { test } from "qunit";
|
2016-08-26 01:14:56 +08:00
|
|
|
|
2016-11-26 03:29:24 +08:00
|
|
|
moduleFor("model:wizard-field");
|
2016-08-26 01:14:56 +08:00
|
|
|
|
2020-10-31 00:37:32 +08:00
|
|
|
test("basic state", function (assert) {
|
2016-08-26 01:14:56 +08:00
|
|
|
const w = WizardField.create({ type: "text" });
|
|
|
|
assert.ok(w.get("unchecked"));
|
|
|
|
assert.ok(!w.get("valid"));
|
|
|
|
assert.ok(!w.get("invalid"));
|
|
|
|
});
|
|
|
|
|
2020-10-31 00:37:32 +08:00
|
|
|
test("text - required - validation", function (assert) {
|
2016-08-26 01:14:56 +08:00
|
|
|
const w = WizardField.create({ type: "text", required: true });
|
|
|
|
assert.ok(w.get("unchecked"));
|
|
|
|
|
|
|
|
w.check();
|
|
|
|
assert.ok(!w.get("unchecked"));
|
|
|
|
assert.ok(!w.get("valid"));
|
|
|
|
assert.ok(w.get("invalid"));
|
|
|
|
|
|
|
|
w.set("value", "a value");
|
|
|
|
w.check();
|
|
|
|
assert.ok(!w.get("unchecked"));
|
|
|
|
assert.ok(w.get("valid"));
|
|
|
|
assert.ok(!w.get("invalid"));
|
|
|
|
});
|
|
|
|
|
2020-10-31 00:37:32 +08:00
|
|
|
test("text - optional - validation", function (assert) {
|
2016-09-21 00:28:22 +08:00
|
|
|
const f = WizardField.create({ type: "text" });
|
|
|
|
assert.ok(f.get("unchecked"));
|
2016-08-26 01:14:56 +08:00
|
|
|
|
2016-09-21 00:28:22 +08:00
|
|
|
f.check();
|
|
|
|
assert.ok(f.get("valid"));
|
2016-08-26 01:14:56 +08:00
|
|
|
});
|