Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Commit

Permalink
style: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined committed May 24, 2021
1 parent 18e528c commit 8bdaee1
Show file tree
Hide file tree
Showing 27 changed files with 1,513 additions and 1,515 deletions.
40 changes: 20 additions & 20 deletions src/useClickAway/__demo__/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { Component, ref, defineComponent } from 'vue';
import useClickAway from '../index';
export default defineComponent({
setup() {
const count = ref(0);
const eleRef = ref(null);
useClickAway(eleRef, () => {
count.value++;
});
return { eleRef, count };
},
render(_ctx) {
return (
<div>
<button ref="eleRef">click away</button>
<div>count:{_ctx.count}</div>
</div>
);
},
}) as Component;
import { Component, ref, defineComponent } from 'vue';
import useClickAway from '../index';
export default defineComponent({
setup() {
const count = ref(0);
const eleRef = ref(null);
useClickAway(eleRef, () => {
count.value++;
});
return { eleRef, count };
},
render(_ctx) {
return (
<div>
<button ref="eleRef">click away</button>
<div>count:{_ctx.count}</div>
</div>
);
},
}) as Component;
72 changes: 36 additions & 36 deletions src/useClickAway/__test__/index.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import { mount } from '@vue/test-utils';

import useClickAway from '../index';
import { ref } from 'vue';

describe('useClickAway', () => {
test('should work with custom funtion', async () => {
// eslint-disable-next-line @typescript-eslint/no-empty-function
const fn = jest.fn(() => {});
const eleRef = ref(null);
const wrapRef = ref(null);
let removeListener!: () => void;
const wrapper = mount({
setup() {
removeListener = useClickAway(eleRef, fn, 'click', wrapRef);
return { eleRef, wrapRef };
},
render() {
return (
<div ref="wrapRef">
<h1 ref="eleRef"></h1>
<h2>h2</h2>
</div>
);
},
});
await wrapper.vm.$nextTick();
wrapper.find('h1').trigger('click');
expect(fn).toHaveBeenCalledTimes(0);
wrapper.find('h2').trigger('click');
expect(fn).toHaveBeenCalledTimes(1);
removeListener();
wrapper.find('h2').trigger('click');
expect(fn).toHaveBeenCalledTimes(1);
});
});
import { mount } from '@vue/test-utils';

import useClickAway from '../index';
import { ref } from 'vue';

describe('useClickAway', () => {
test('should work with custom funtion', async () => {
// eslint-disable-next-line @typescript-eslint/no-empty-function
const fn = jest.fn(() => {});
const eleRef = ref(null);
const wrapRef = ref(null);
let removeListener!: () => void;
const wrapper = mount({
setup() {
removeListener = useClickAway(eleRef, fn, 'click', wrapRef);
return { eleRef, wrapRef };
},
render() {
return (
<div ref="wrapRef">
<h1 ref="eleRef"></h1>
<h2>h2</h2>
</div>
);
},
});
await wrapper.vm.$nextTick();
wrapper.find('h1').trigger('click');
expect(fn).toHaveBeenCalledTimes(0);
wrapper.find('h2').trigger('click');
expect(fn).toHaveBeenCalledTimes(1);
removeListener();
wrapper.find('h2').trigger('click');
expect(fn).toHaveBeenCalledTimes(1);
});
});
36 changes: 18 additions & 18 deletions src/useDraggable/__demo__/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { Component, defineComponent } from 'vue';
import useDraggable from '../index';
export default defineComponent({
setup() {
const [targetRef, handleRef, { delta }] = useDraggable({ controlStyle: true });
return () => {
return (
<>
<div style="height:100px;width:100px;background: #999;" ref={targetRef}>
<button ref={handleRef}>handle</button>
</div>
<h2>{delta.value.x}</h2>
<h2>{delta.value.y}</h2>
</>
);
};
},
}) as Component;
import { Component, defineComponent } from 'vue';
import useDraggable from '../index';
export default defineComponent({
setup() {
const [targetRef, handleRef, { delta }] = useDraggable({ controlStyle: true });
return () => {
return (
<>
<div style="height:100px;width:100px;background: #999;" ref={targetRef}>
<button ref={handleRef}>handle</button>
</div>
<h2>{delta.value.x}</h2>
<h2>{delta.value.y}</h2>
</>
);
};
},
}) as Component;
Loading

0 comments on commit 8bdaee1

Please sign in to comment.