-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(emeisOptions): make user filter optionally visible (#648)
- Loading branch information
1 parent
ef10648
commit 107b7de
Showing
7 changed files
with
191 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { helper } from "@ember/component/helper"; | ||
|
||
export default helper(function evaluateToBoolean([expression, ...parameter]) { | ||
if (typeof expression === "boolean") { | ||
return expression; | ||
} | ||
if (typeof expression === "function") { | ||
return expression(...parameter); | ||
} | ||
if (typeof expression === "string") { | ||
return expression === "true"; | ||
} | ||
return false; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "ember-emeis/helpers/evaluate-to-boolean"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { render } from "@ember/test-helpers"; | ||
import { hbs } from "ember-cli-htmlbars"; | ||
import { setupRenderingTest } from "ember-qunit"; | ||
import { module, test } from "qunit"; | ||
|
||
module("Integration | Helper | evaluateToBoolean", function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test("evaluates booleans (true)", async function (assert) { | ||
this.set("inputValue", true); | ||
|
||
await render( | ||
hbs`{{if (evaluate-to-boolean this.inputValue) "true" "false"}}` | ||
); | ||
|
||
assert.dom(this.element).hasText("true"); | ||
}); | ||
|
||
test("evaluates booleans (false)", async function (assert) { | ||
this.set("inputValue", false); | ||
|
||
await render( | ||
hbs`{{if (evaluate-to-boolean this.inputValue) "true" "false"}}` | ||
); | ||
|
||
assert.dom(this.element).hasText("false"); | ||
}); | ||
|
||
test("evaluates string (true)", async function (assert) { | ||
this.set("inputValue", "true"); | ||
|
||
await render( | ||
hbs`{{if (evaluate-to-boolean this.inputValue) "true" "false"}}` | ||
); | ||
|
||
assert.dom(this.element).hasText("true"); | ||
}); | ||
|
||
test("evaluates string (false)", async function (assert) { | ||
this.set("inputValue", "false"); | ||
|
||
await render( | ||
hbs`{{if (evaluate-to-boolean this.inputValue) "true" "false"}}` | ||
); | ||
|
||
assert.dom(this.element).hasText("false"); | ||
}); | ||
|
||
test("evaluates function (true)", async function (assert) { | ||
this.set("inputValue", () => true); | ||
|
||
await render( | ||
hbs`{{if (evaluate-to-boolean this.inputValue) "true" "false"}}` | ||
); | ||
|
||
assert.dom(this.element).hasText("true"); | ||
}); | ||
|
||
test("evaluates function (false)", async function (assert) { | ||
this.set("inputValue", () => false); | ||
|
||
await render( | ||
hbs`{{if (evaluate-to-boolean this.inputValue) "true" "false"}}` | ||
); | ||
|
||
assert.dom(this.element).hasText("false"); | ||
}); | ||
|
||
test("evaluates function with parameter (false)", async function (assert) { | ||
this.set("inputValue", (p) => p === 1); | ||
|
||
await render( | ||
hbs`{{if (evaluate-to-boolean this.inputValue 2) "true" "false"}}` | ||
); | ||
|
||
assert.dom(this.element).hasText("false"); | ||
}); | ||
|
||
test("evaluates function with multiple parameters (true)", async function (assert) { | ||
this.set("inputValue", (p1, p2) => p1 !== p2); | ||
|
||
await render( | ||
hbs`{{if (evaluate-to-boolean this.inputValue 1 "a") "true" "false"}}` | ||
); | ||
|
||
assert.dom(this.element).hasText("true"); | ||
}); | ||
}); |