Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
test(index-controller): remove unnecessary service stub
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabauke committed Dec 20, 2022
1 parent 8eb6cd6 commit b1338fd
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 112 deletions.
60 changes: 33 additions & 27 deletions app/components/optimized-power-select/trigger/template.hbs
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}}
>&times;</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}}
>&times;</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>
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 tests/integration/components/power-select/component-test.js

This file was deleted.

5 changes: 0 additions & 5 deletions tests/unit/index/controller-test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { setupTest } from "ember-qunit";
import { module, test } from "qunit";
import { setup as setupTrackingStub } from "timed/tests/helpers/tracking-mock";

module("Unit | Controller | index", function (hooks) {
setupTest(hooks);

hooks.beforeEach(function () {
setupTrackingStub(this);
});

test("exists", function (assert) {
const controller = this.owner.lookup("controller:index");
assert.ok(controller);
Expand Down

0 comments on commit b1338fd

Please sign in to comment.