Skip to content

Commit 341ccc3

Browse files
committed
tests: add test for enum collection filter on c-input
1 parent d8fdebb commit 341ccc3

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/coalesce-vue-vuetify3/src/components/input/c-input.spec.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ describe("CInput", () => {
209209

210210
// Open the dropdown and select the 4th item.
211211
await wrapper.find(".v-field").trigger("mousedown");
212+
expect(wrapper.text()).not.contains(
213+
model.$metadata.props.status.typeDef.valueLookup.ClosedNoSolution
214+
.displayName,
215+
);
212216
await wrapper.findAllComponents(VListItem)[3].trigger("click");
213217

214218
// The selected value should now be the 4th value of the list,
@@ -217,6 +221,36 @@ describe("CInput", () => {
217221
expect(wrapper.text()).contains("Cancelled");
218222
});
219223

224+
test("enums filtered", async () => {
225+
const model = new ComplexModelViewModel({
226+
enumCollection: [Statuses.InProgress],
227+
});
228+
const wrapper = mount(() => (
229+
<CInput
230+
model={model}
231+
for="enumCollection"
232+
filter={(v) => v.value != Statuses.ClosedNoSolution}
233+
/>
234+
));
235+
236+
// Open the dropdown and select the 4th item.
237+
await wrapper.find(".v-field").trigger("mousedown");
238+
expect(wrapper.text()).not.contains(
239+
model.$metadata.props.enumCollection.itemType.typeDef.valueLookup
240+
.ClosedNoSolution.displayName,
241+
);
242+
await wrapper.findAllComponents(VListItem)[3].trigger("click");
243+
244+
// The selected value should now be the 4th value of the list,
245+
// which is the 5th value of the enum because ClosedNoSolution was the 4th and we filtered it out.
246+
expect(model.enumCollection).toMatchObject([
247+
Statuses.InProgress,
248+
Statuses.Cancelled,
249+
]);
250+
expect(wrapper.text()).contains("In Progress");
251+
expect(wrapper.text()).contains("Cancelled");
252+
});
253+
220254
test("caller model - date value", async () => {
221255
const wrapper = mount(() => (
222256
<CInput model={model.methodWithManyParams} for="dateTime" />

0 commit comments

Comments
 (0)