mirror of https://github.com/status-im/consul.git
parent
328874ad4f
commit
db1ed14acf
|
@ -1,7 +0,0 @@
|
|||
<input id={{concat 'sort-control-value-' elementId}} type="radio" value="Name" name={{concat 'sort-control-' name}} onchange={{action 'change'}} />
|
||||
{{#if checked}}
|
||||
<input id={{concat 'sort-control-direction-' elementId}} type="checkbox" onchange={{action 'change'}} />
|
||||
{{/if}}
|
||||
<label for={{if checked (concat 'sort-control-direction-' elementId) (concat 'sort-control-value-' elementId)}}>
|
||||
{{yield}}
|
||||
</label>
|
|
@ -1,15 +0,0 @@
|
|||
import Component from '@ember/component';
|
||||
import { set } from '@ember/object';
|
||||
export default Component.extend({
|
||||
classNames: ['sort-control'],
|
||||
direction: 'asc',
|
||||
onchange: function() {},
|
||||
actions: {
|
||||
change: function(e) {
|
||||
if (e.target.type === 'checkbox') {
|
||||
set(this, 'direction', e.target.checked ? 'desc' : 'asc');
|
||||
}
|
||||
this.onchange({ target: { value: `${this.value}:${this.direction}` } });
|
||||
},
|
||||
},
|
||||
});
|
|
@ -1,47 +0,0 @@
|
|||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'ember-qunit';
|
||||
import { render } from '@ember/test-helpers';
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
|
||||
module('Integration | Component | sort control', function(hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function() {
|
||||
this.actions = {};
|
||||
this.send = (actionName, ...args) => this.actions[actionName].apply(this, args);
|
||||
});
|
||||
|
||||
test('it renders', async function(assert) {
|
||||
// Set any properties with this.set('myProperty', 'value');
|
||||
// Handle any actions with this.on('myAction', function(val) { ... });
|
||||
|
||||
await render(hbs`{{sort-control}}`);
|
||||
|
||||
assert.dom('*').hasText('');
|
||||
|
||||
// Template block usage:
|
||||
await render(hbs`
|
||||
{{#sort-control}}
|
||||
template block text
|
||||
{{/sort-control}}
|
||||
`);
|
||||
|
||||
assert.dom('*').hasText('template block text');
|
||||
});
|
||||
test('it changes direction and calls onchange when clicked/activated', async function(assert) {
|
||||
assert.expect(2);
|
||||
let count = 0;
|
||||
this.actions.change = e => {
|
||||
if (count === 0) {
|
||||
assert.equal(e.target.value, 'sort:desc');
|
||||
} else {
|
||||
assert.equal(e.target.value, 'sort:asc');
|
||||
}
|
||||
count++;
|
||||
};
|
||||
await render(hbs`{{sort-control checked=true value='sort' onchange=(action 'change')}}`);
|
||||
const $label = this.$('label');
|
||||
$label.trigger('click');
|
||||
$label.trigger('click');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue