Code is coming from https://github.com/jmurphyau/ember-truth-helpers, for now I only ported {{not}} which would have tons of use cases in our code base. We might want to use more helpers in the future, also Ember should have this kind of helpers natively in the future: - https://github.com/cibernox/rfcs/blob/add-logical-operators-to-templates/text/0000-add-logical-operators.md - https://github.com/cibernox/rfcs/blob/add-equality-operators-to-templates/text/0000-add-equality-operators.md - https://github.com/cibernox/rfcs/blob/add-numeric-comparison-operators-to-templates/text/0561-add-numeric-comparison-operators.md
35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
// https://github.com/jmurphyau/ember-truth-helpers/blob/master/tests/unit/helpers/not-test.js
|
|
import componentTest, {
|
|
setupRenderingTest,
|
|
} from "discourse/tests/helpers/component-test";
|
|
import { discourseModule, query } from "discourse/tests/helpers/qunit-helpers";
|
|
import hbs from "htmlbars-inline-precompile";
|
|
|
|
discourseModule("Unit | Helper | not", function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
componentTest("simple test 1", {
|
|
template: hbs`<div id="not-test">[{{not true}}] [{{not false}}] [{{not null}}] [{{not undefined}}] [{{not ''}}] [{{not ' '}}]</div>`,
|
|
|
|
test(assert) {
|
|
assert.equal(
|
|
query("#not-test").textContent,
|
|
"[false] [true] [true] [true] [true] [false]",
|
|
'value should be "[false] [true] [true] [true] [true] [false]"'
|
|
);
|
|
},
|
|
});
|
|
|
|
componentTest("simple test 2", {
|
|
template: hbs`<div id="not-test">[{{not true false}}] [{{not true false}}] [{{not null null false null}}] [{{not false null ' ' true}}]</div>`,
|
|
|
|
test(assert) {
|
|
assert.equal(
|
|
query("#not-test").textContent,
|
|
"[false] [false] [true] [false]",
|
|
'value should be "[false] [false] [true] [false]"'
|
|
);
|
|
},
|
|
});
|
|
});
|