2018-06-15 11:03:24 -04:00
|
|
|
import WizardField from "wizard/models/wizard-field";
|
2016-08-25 13:14:56 -04:00
|
|
|
|
2016-11-25 14:29:24 -05:00
|
|
|
moduleFor("model:wizard-field");
|
2016-08-25 13:14:56 -04:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
test("basic state", assert => {
|
|
|
|
const w = WizardField.create({ type: "text" });
|
|
|
|
assert.ok(w.get("unchecked"));
|
|
|
|
assert.ok(!w.get("valid"));
|
|
|
|
assert.ok(!w.get("invalid"));
|
2016-08-25 13:14:56 -04:00
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
test("text - required - validation", assert => {
|
|
|
|
const w = WizardField.create({ type: "text", required: true });
|
|
|
|
assert.ok(w.get("unchecked"));
|
2016-08-25 13:14:56 -04:00
|
|
|
|
|
|
|
w.check();
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.ok(!w.get("unchecked"));
|
|
|
|
assert.ok(!w.get("valid"));
|
|
|
|
assert.ok(w.get("invalid"));
|
2016-08-25 13:14:56 -04:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
w.set("value", "a value");
|
2016-08-25 13:14:56 -04:00
|
|
|
w.check();
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.ok(!w.get("unchecked"));
|
|
|
|
assert.ok(w.get("valid"));
|
|
|
|
assert.ok(!w.get("invalid"));
|
2016-08-25 13:14:56 -04:00
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
test("text - optional - validation", assert => {
|
|
|
|
const f = WizardField.create({ type: "text" });
|
|
|
|
assert.ok(f.get("unchecked"));
|
2016-08-25 13:14:56 -04:00
|
|
|
|
2016-09-20 12:28:22 -04:00
|
|
|
f.check();
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.ok(f.get("valid"));
|
2016-08-25 13:14:56 -04:00
|
|
|
});
|