Skip to content

Commit

Permalink
test: modify query (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
seaneez authored Mar 18, 2024
1 parent d6a9df9 commit df59e4b
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ describe('vs-chip', () => {

it('close 버튼이 렌더된다', () => {
// then
expect(wrapper.find('button[aria-label="close"]').exists()).toBe(true);
expect(wrapper.find('button.close-button').exists()).toBe(true);
});

it('close 버튼이 눌렸을 때 close 함수를 한번 emit 한다', async () => {
// when
const closeBtn = wrapper.find('button[aria-label="close"]');
const closeBtn = wrapper.find('button.close-button');
await closeBtn.trigger('click');

// then
Expand All @@ -63,7 +63,7 @@ describe('vs-chip', () => {
});

// then
expect(wrapper.find('button[aria-label="close"]').exists()).toBe(false);
expect(wrapper.find('button.close-button').exists()).toBe(false);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('vs-confirm', () => {
});

// then
const okButtons = document.querySelectorAll('button[aria-label="ok"]');
const okButtons = document.querySelectorAll('button.ok-button');
const targetButton = okButtons[okButtons.length - 1];
expect(targetButton?.textContent).toContain(okText);
});
Expand All @@ -72,7 +72,7 @@ describe('vs-confirm', () => {
});

// then
const cancelButtons = document.querySelectorAll('button[aria-label="cancel"]');
const cancelButtons = document.querySelectorAll('button.cancel-button');
const targetButton = cancelButtons[cancelButtons.length - 1];
expect(targetButton?.textContent).toContain(cancelText);
});
Expand All @@ -91,7 +91,7 @@ describe('vs-confirm', () => {
});

// when
const okButtons = document.querySelectorAll('button[aria-label="ok"]');
const okButtons = document.querySelectorAll('button.ok-button');
const targetButton = okButtons[okButtons.length - 1];
targetButton.dispatchEvent(new Event('click'));

Expand All @@ -117,7 +117,7 @@ describe('vs-confirm', () => {
});

// when
const cancelButtons = document.querySelectorAll('button[aria-label="cancel"]');
const cancelButtons = document.querySelectorAll('button.cancel-button');
const targetButton = cancelButtons[cancelButtons.length - 1];
targetButton.dispatchEvent(new Event('click'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('vs-drawer', () => {
});

// then
expect(wrapper.find('[role="dialog"]').exists()).toBe(false);
expect(wrapper.find('div.vs-dialog').exists()).toBe(false);
});

it('modelValue가 true이면 drawer가 열린다', async () => {
Expand All @@ -30,13 +30,13 @@ describe('vs-drawer', () => {
},
});

expect(wrapper.find('[role="dialog"]').exists()).toBe(false);
expect(wrapper.find('div.vs-dialog').exists()).toBe(false);

// when
await wrapper.setProps({ modelValue: true });

// then
expect(wrapper.find('[role="dialog"]').exists()).toBe(true);
expect(wrapper.find('div.vs-dialog').exists()).toBe(true);
});
});

Expand Down Expand Up @@ -127,7 +127,7 @@ describe('vs-drawer', () => {
});

// then
expect(wrapper.find('div[aria-hidden="true"]').exists()).toBe(true);
expect(wrapper.find('div.dimmed').exists()).toBe(true);
});

it('dimmed prop을 false로 전달하면 dimmed 영역이 존재하지 않는다', () => {
Expand All @@ -143,7 +143,7 @@ describe('vs-drawer', () => {
});

// then
expect(wrapper.find('div[aria-hidden="true"]').exists()).toBe(false);
expect(wrapper.find('div.dimmed').exists()).toBe(false);
});

it('기본적으로 dimmed 영역 클릭 시 drawer가 닫힌다', async () => {
Expand All @@ -158,7 +158,7 @@ describe('vs-drawer', () => {
});

// when
await wrapper.find('div[aria-hidden="true"]').trigger('click');
await wrapper.find('div.dimmed').trigger('click');

// then
const updateModelValueEvent = wrapper.emitted('update:modelValue');
Expand All @@ -179,7 +179,7 @@ describe('vs-drawer', () => {
});

// when
await wrapper.find('div[aria-hidden="true"]').trigger('click');
await wrapper.find('div.dimmed').trigger('click');

// then
const updateModelValueEvent = wrapper.emitted('update:modelValue');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('vs-modal', () => {
});

// then
expect(wrapper.find('[role="dialog"]').exists()).toBe(false);
expect(wrapper.find('div.vs-dialog').exists()).toBe(false);
});

it('modelValue가 true이면 modal이 열린다', async () => {
Expand All @@ -30,13 +30,13 @@ describe('vs-modal', () => {
},
});

expect(wrapper.find('[role="dialog"]').exists()).toBe(false);
expect(wrapper.find('div.vs-dialog').exists()).toBe(false);

// when
await wrapper.setProps({ modelValue: true });

// then
expect(wrapper.find('[role="dialog"]').exists()).toBe(true);
expect(wrapper.find('div.vs-dialog').exists()).toBe(true);
});
});

Expand Down Expand Up @@ -127,7 +127,7 @@ describe('vs-modal', () => {
});

// then
expect(wrapper.find('div[aria-hidden="true"]').exists()).toBe(true);
expect(wrapper.find('div.dimmed').exists()).toBe(true);
});

it('dimmed 영역 클릭 시 modal이 닫힌다', async () => {
Expand All @@ -142,7 +142,7 @@ describe('vs-modal', () => {
});

// when
await wrapper.find('div[aria-hidden="true"]').trigger('click');
await wrapper.find('div.dimmed').trigger('click');

// then
const updateModelValueEvent = wrapper.emitted('update:modelValue');
Expand All @@ -163,7 +163,7 @@ describe('vs-modal', () => {
});

// when
await wrapper.find('div[aria-hidden="true"]').trigger('click');
await wrapper.find('div.dimmed').trigger('click');

// then
const updateModelValueEvent = wrapper.emitted('update:modelValue');
Expand Down
12 changes: 8 additions & 4 deletions packages/vlossom/src/components/vs-select/VsSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
:aria-setsize="filteredOptions.length"
:aria-posinset="1"
:class="[
'option',
'select-all',
{
selected: isAllSelected,
Expand All @@ -148,10 +149,13 @@
:aria-checked="multiple ? isSelectedOption(option.value) : undefined"
:aria-setsize="filteredOptions.length"
:aria-posinset="(selectAll ? 2 : 1) + index"
:class="{
selected: isSelectedOption(option.value),
chased: isChasedOption(index),
}"
:class="[
'option',
{
selected: isSelectedOption(option.value),
chased: isChasedOption(index),
},
]"
@mousemove="onMouseMove(option)"
@click.stop="selectOption(option.value)"
>
Expand Down
Loading

0 comments on commit df59e4b

Please sign in to comment.