This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/unit/models/wizard-field-test.js
Jarek Radosz fcb4e5a1a1
DEV: Make wizard an ember addon (#17027)
Co-authored-by: David Taylor <david@taylorhq.com>
2022-06-17 14:50:21 +02:00

36 lines
909 B
JavaScript

import { module, test } from "qunit";
import WizardField from "wizard/models/wizard-field";
module("Unit | Model | Wizard | wizard-field", function () {
test("basic state", function (assert) {
const w = WizardField.create({ type: "text" });
assert.ok(w.unchecked);
assert.ok(!w.valid);
assert.ok(!w.invalid);
});
test("text - required - validation", function (assert) {
const w = WizardField.create({ type: "text", required: true });
assert.ok(w.unchecked);
w.check();
assert.ok(!w.unchecked);
assert.ok(!w.valid);
assert.ok(w.invalid);
w.set("value", "a value");
w.check();
assert.ok(!w.unchecked);
assert.ok(w.valid);
assert.ok(!w.invalid);
});
test("text - optional - validation", function (assert) {
const f = WizardField.create({ type: "text" });
assert.ok(f.unchecked);
f.check();
assert.ok(f.valid);
});
});