2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 10:50:21 +08:00

FEATURE: implements minimum selection for select-kit

This commit is contained in:
Joffrey JAFFEUX 2018-04-05 16:45:19 +02:00 committed by GitHub
parent cd6a99a027
commit f0fe16d824
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 186 additions and 52 deletions

View file

@ -501,3 +501,44 @@ componentTest('with limitMatches', {
andThen(() => assert.equal(this.get('subject').el().find(".select-kit-row").length, 2));
}
});
componentTest('with minimum', {
template: '{{single-select content=content minimum=1 allowAutoSelectFirst=false}}',
beforeEach() {
this.set('content', ['sam', 'jeff', 'neil']);
},
test(assert) {
this.get('subject').expand();
andThen(() => assert.equal(this.get('subject').validationMessage(), 'Select at least 1 item(s).'));
this.get('subject').selectRowByValue('sam');
andThen(() => {
assert.equal(this.get('subject').header().label(), 'sam');
});
}
});
componentTest('with minimumLabel', {
template: '{{single-select content=content minimum=1 minimumLabel="test.minimum" allowAutoSelectFirst=false}}',
beforeEach() {
I18n.translations[I18n.locale].js.test = { minimum: 'min %{count}' };
this.set('content', ['sam', 'jeff', 'neil']);
},
test(assert) {
this.get('subject').expand();
andThen(() => assert.equal(this.get('subject').validationMessage(), 'min 1'));
this.get('subject').selectRowByValue('jeff');
andThen(() => {
assert.equal(this.get('subject').header().label(), 'jeff');
});
}
});