This repository has been archived by the owner on May 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(index-controller): remove unnecessary service stub
- Loading branch information
1 parent
8eb6cd6
commit b1338fd
Showing
4 changed files
with
116 additions
and
112 deletions.
There are no files selected for viewing
60 changes: 33 additions & 27 deletions
60
app/components/optimized-power-select/trigger/template.hbs
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 |
---|---|---|
@@ -1,30 +1,36 @@ | ||
{{#if @select.selected}} | ||
{{#if @selectedItemComponent}} | ||
<div class={{@triggerClass}}> | ||
{{#if @select.selected}} | ||
{{#if @selectedItemComponent}} | ||
{{component | ||
@selectedItemComponent | ||
option=(readonly @select.selected) | ||
select=(readonly @select) | ||
}} | ||
{{else}} | ||
<span class="ember-power-select-selected-item"> | ||
{{#if @extra.selectedTemplate}} | ||
{{component | ||
(ensure-safe-component @extra.selectedTemplate) | ||
selected=@select.selected | ||
}} | ||
{{else}} | ||
{{yield @select.selected @select}} | ||
{{/if}} | ||
</span> | ||
{{/if}} | ||
{{#if (and @allowClear (not @select.disabled))}} | ||
<span | ||
role="button" | ||
class="ember-power-select-clear-btn" | ||
{{on "mouseup" this.clear}} | ||
{{on "ontouchend" this.clear}} | ||
>×</span> | ||
{{/if}} | ||
{{else}} | ||
{{component | ||
@selectedItemComponent | ||
option=(readonly @select.selected) | ||
select=(readonly @select) | ||
(ensure-safe-component @placeholderComponent) | ||
placeholder=@placeholder | ||
}} | ||
{{else}} | ||
<span class="ember-power-select-selected-item"> | ||
{{#if @extra.selectedTemplate}} | ||
{{component (ensure-safe-component @extra.selectedTemplate) selected=@select.selected}} | ||
{{else}} | ||
{{yield @select.selected @select}} | ||
{{/if}} | ||
</span> | ||
{{/if}} | ||
{{#if (and @allowClear (not @select.disabled))}} | ||
<span | ||
class="ember-power-select-clear-btn" | ||
{{on "mousedown" this.clear}} | ||
{{on "ontouchstart" this.clear}} | ||
>×</span> | ||
{{/if}} | ||
{{else}} | ||
{{component | ||
(ensure-safe-component @placeholderComponent) | ||
placeholder=@placeholder | ||
}} | ||
{{/if}} | ||
<span class="ember-power-select-status-icon"></span> | ||
<span class="ember-power-select-status-icon"></span> | ||
</div> |
83 changes: 83 additions & 0 deletions
83
tests/integration/components/optimized-power-select/component-test.js
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,83 @@ | ||
import { triggerKeyEvent, render } from "@ember/test-helpers"; | ||
import { hbs } from "ember-cli-htmlbars"; | ||
import { | ||
typeInSearch, | ||
clickTrigger, | ||
} from "ember-power-select/test-support/helpers"; | ||
import { setupRenderingTest } from "ember-qunit"; | ||
import { module, test } from "qunit"; | ||
import taskOptionTemplate from "timed/components/optimized-power-select/custom-options/task-option"; | ||
import customSelectedTemplate from "timed/components/optimized-power-select/custom-select/task-selection"; | ||
|
||
const OPTIONS = [ | ||
{ id: 1, name: "Test 1" }, | ||
{ id: 2, name: "Test 2" }, | ||
{ id: 3, name: "Test 3" }, | ||
]; | ||
|
||
module("Integration | Component | optimized power select", function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test("can use blockless", async function (assert) { | ||
this.set("options", OPTIONS); | ||
this.set("selected", OPTIONS[0]); | ||
|
||
this.set("selectedTemplate", customSelectedTemplate); | ||
this.set("optionTemplate", taskOptionTemplate); | ||
|
||
await render(hbs` | ||
{{(component | ||
(ensure-safe-component "optimized-power-select") | ||
options = this.options | ||
selected = this.selected | ||
onChange = (fn (mut this.selected)) | ||
tagName = 'div' | ||
renderInPlace = true | ||
searchField = 'name' | ||
extra = (hash | ||
optionTemplate = this.optionTemplate | ||
selectedTemplate = this.selectedTemplate | ||
) | ||
) | ||
}} | ||
`); | ||
|
||
await clickTrigger(); | ||
|
||
assert.dom(".ember-power-select-selected-item").hasText("Test 1"); | ||
assert.dom(".ember-power-select-option:first-of-type").hasText("Test 1"); | ||
}); | ||
|
||
test("can select with return key", async function (assert) { | ||
assert.expect(1); | ||
this.set("options", OPTIONS); | ||
this.set("selected", OPTIONS[0]); | ||
|
||
this.set("selectedTemplate", customSelectedTemplate); | ||
this.set("optionTemplate", taskOptionTemplate); | ||
|
||
await render(hbs` | ||
{{(component | ||
(ensure-safe-component "optimized-power-select") | ||
options = this.options | ||
selected = this.selected | ||
onChange = (fn (mut this.selected)) | ||
tagName = 'div' | ||
renderInPlace = true | ||
searchField = 'name' | ||
extra = (hash | ||
optionTemplate = this.optionTemplate | ||
selectedTemplate = this.selectedTemplate | ||
) | ||
) | ||
}} | ||
`); | ||
|
||
await clickTrigger(); | ||
await typeInSearch("2"); | ||
|
||
await triggerKeyEvent(".ember-power-select-search-input", "keydown", 13); | ||
|
||
assert.strictEqual(this.get("selected.id"), 2); | ||
}); | ||
}); |
80 changes: 0 additions & 80 deletions
80
tests/integration/components/power-select/component-test.js
This file was deleted.
Oops, something went wrong.
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