Commit 93fca584 authored by Kev's avatar Kev

Improve selection_summary_spec.js tests

This improves the tests of the selection_summary_spec.js by switching to
async/await and replacing the "ref" attribute with a "data-testid" one.
parent 90dd0053
......@@ -103,7 +103,7 @@ export default {
<template>
<div class="card">
<form class="card-body d-flex align-items-center" @submit.prevent="handleDismiss">
<span ref="dismiss-message">{{ message }}</span>
<span data-testid="dismiss-message">{{ message }}</span>
<gl-form-select
v-model="dismissalReason"
class="mx-3 w-auto"
......
......@@ -23,7 +23,7 @@ describe('Selection Summary component', () => {
};
const dismissButton = () => wrapper.find(GlButton);
const dismissMessage = () => wrapper.find({ ref: 'dismiss-message' });
const dismissMessage = () => wrapper.find('[data-testid="dismiss-message"]');
const formSelect = () => wrapper.find(GlFormSelect);
const createComponent = ({ props = {}, data = defaultData, mocks = defaultMocks } = {}) => {
spyMutate = mocks.$apollo.mutate;
......@@ -62,14 +62,15 @@ describe('Selection Summary component', () => {
it('should have the button enabled if a vulnerability is selected and an option is selected', async () => {
expect(wrapper.vm.dismissalReason).toBe(null);
expect(wrapper.findAll('option')).toHaveLength(4);
formSelect()
const option = formSelect()
.findAll('option')
.at(1)
.setSelected();
.at(1);
option.setSelected();
formSelect().trigger('change');
await wrapper.vm.$nextTick();
expect(wrapper.vm.dismissalReason).toEqual(expect.any(String));
await wrapper.vm.$nextTick();
expect(wrapper.vm.dismissalReason).toEqual(option.attributes('value'));
expect(dismissButton().attributes('disabled')).toBe(undefined);
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment