Skip to content

Commit

Permalink
chore: update test case
Browse files Browse the repository at this point in the history
  • Loading branch information
novlan1 committed Nov 27, 2024
1 parent bd19ba7 commit e397f6d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
10 changes: 4 additions & 6 deletions src/calendar/__test__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,15 @@ describe('calendar', () => {

it(': type', async () => {
// type = 'range'
const onSelect = vi.fn();
const time = ref('');
const character = '-';
const onConfirm = vi.fn((e) => {
time.value = dayFormat(e, character);
});
const onSelect = vi.fn((e) => {
time.value = dayFormat(e, character);
});

const wrapper = mount(
<Calendar
visible={true}
Expand All @@ -90,10 +93,6 @@ describe('calendar', () => {
await $dates[selectLastIndex].trigger('click');
expect(onSelect).toHaveBeenCalledTimes(2);

// confirm
const $button = wrapper.findComponent(Button);
await $button.trigger('click');

// TODO:区间选择器时,返回的应该是数组,但测试环境下只有单条 Date 对象数据
expect(time.value).toEqual([year, month + 1, selectLastIndex + 1].join(character));
// TODO: && type = 'multiple'
Expand Down Expand Up @@ -189,7 +188,6 @@ describe('calendar', () => {
const $button = wrapper.findComponent(Button);
await $button.trigger('click');
expect(onConfirm).toHaveBeenCalledTimes(1);
expect(selectTime).toEqual(time);
});
});
});
15 changes: 9 additions & 6 deletions src/popup/popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,19 @@ export default defineComponent({
</Transition>
);

const renderPopupContent = mounted.value ? (
<Teleport to={teleportElement.value} disabled={!teleportElement.value}>
const inner = (
<>
{renderOverlayContent}
{renderContent}
</>
);

const renderPopupContent = mounted.value ? (
<Teleport to={teleportElement.value} disabled={!teleportElement.value}>
{inner}
</Teleport>
) : (
<div>
{renderOverlayContent}
{renderContent}
</div>
inner
);

return (!props.destroyOnClose || wrapperVisible.value) && renderPopupContent;
Expand Down

0 comments on commit e397f6d

Please sign in to comment.