2
0
mirror of https://github.com/tenrok/vue-select.git synced 2026-05-17 02:29:37 +03:00

Reduce null values (#940)

* support falsey values with reduce

* support null values with reduce
This commit is contained in:
Jeff Sagal
2019-09-14 13:53:16 -07:00
committed by GitHub
parent aecbde8343
commit dff8f750a7
2 changed files with 15 additions and 1 deletions
+14
View File
@@ -166,6 +166,20 @@ describe("When reduce prop is defined", () => {
expect(Select.vm.selectedValue).toEqual([option]);
});
it('works with null values', () => {
const option = {value: null, label: 'No'};
const Select = shallowMount(VueSelect, {
propsData: {
reduce: option => option.value,
options: [option, {value: 1, label: 'Yes'}],
value: null,
},
});
expect(Select.vm.findOptionFromReducedValue(option)).toEqual(option);
expect(Select.vm.selectedValue).toEqual([option]);
});
describe("And when a reduced option is a nested object", () => {
it("can determine if an object is pre-selected", () => {
const nestedOption = { value: { nested: true }, label: "foo" };