This is a migrated thread and some comments may be shown as answers.

[JEST] testing combobox wrapper component

1 Answer 597 Views
This is a migrated thread and some comments may be shown as answers.
Le Lan
Top achievements
Rank 1
Le Lan asked on 17 Feb 2020, 08:08 PM

Hello everyone!

I am trying to implement a search field component based on kendo-combobox wrapper.

I want to cover via JEST unit tests the changed value but I can not trigger the change event and assert the component value.

I am sharing with you guys this code example : https://codesandbox.io/s/tender-proskuriakova-89bcm?fontsize=14&hidenavigation=1&theme=dark

Can you help me on this assertion : expect(wrapper.vm.$data.value).toEqual(1);

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin
Telerik team
answered on 19 Feb 2020, 05:01 PM

Hello Le Lan,

Thank you for the example.

I reviewed it and I noticed that the test in question is not being executed at all. Unfortunately I was unable to discover the reason for that.

What I could offer is to demonstrate how to get a reference to the ComboBox and trigger the change event. You can add ref to the initialization of the ComboBox like below:

 <kendo-combobox ref="combo"

You can then get a reference to the widget like below:

    mounted: function(){
      var combobox = this.$refs.combo.kendoWidget();
      combobox.trigger("change")
    },
    methods:{
        onChange: function(e) {
            console.log("Event :: change");
        }
    }

Here you will find a small example for reference.

Let me know if the above was helpful.

Regards,
Martin
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Asked by
Le Lan
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or