>) => {
const value = arr
.map((row: any[]) => {
return row.join('\t');
})
.join('\n');
- copyUtils.copy(value);
+ await copy(value);
return false;
};
diff --git a/src/useCookieListener/__tests__/useCookieListener.test.tsx b/src/useCookieListener/__tests__/useCookieListener.test.tsx
index bd516aeba..37a013fbe 100644
--- a/src/useCookieListener/__tests__/useCookieListener.test.tsx
+++ b/src/useCookieListener/__tests__/useCookieListener.test.tsx
@@ -104,7 +104,7 @@ describe('test cookies', () => {
});
});
- test('should trigger with prevCookies and nextCookies when change cookie with empty watchfields', () => {
+ test('should trigger with prevValue and nextValue when change cookie with empty watchfields', () => {
const mockCookiesChanged = jest.fn();
const timeout = 200;
@@ -117,8 +117,11 @@ describe('test cookies', () => {
setTimeout(() => {
expect(mockCookiesChanged.mock.calls).toHaveLength(1);
expect(mockCookiesChanged).toBeCalledWith({
- prevCookies: '',
- nextCookies: 'dt_token=token1; dt_userId=123',
+ prevValue: {},
+ nextValue: {
+ dt_token: 'token1',
+ dt_userId: '123',
+ },
});
resolve(true);
}, timeout);
@@ -144,12 +147,21 @@ describe('test cookies', () => {
setTimeout(() => {
expect(mockCookiesChanged.mock.calls).toHaveLength(2);
expect(mockCookiesChanged.mock.calls[0][0]).toEqual({
- prevCookies: '',
- nextCookies: 'dt_token=token1; dt_userId=123',
+ prevValue: {},
+ nextValue: {
+ dt_token: 'token1',
+ dt_userId: '123',
+ },
});
expect(mockCookiesChanged.mock.calls[1][0]).toEqual({
- prevCookies: 'dt_token=token1; dt_userId=123',
- nextCookies: 'dt_token=token2; dt_userId=1234',
+ prevValue: {
+ dt_token: 'token1',
+ dt_userId: '123',
+ },
+ nextValue: {
+ dt_token: 'token2',
+ dt_userId: '1234',
+ },
});
resolve(true);
}, 2 * timeout);
diff --git a/src/useCookieListener/demos/advanced.tsx b/src/useCookieListener/demos/advanced.tsx
index ca15ecddb..0588f5b5b 100644
--- a/src/useCookieListener/demos/advanced.tsx
+++ b/src/useCookieListener/demos/advanced.tsx
@@ -1,12 +1,12 @@
import React, { useEffect } from 'react';
-import { Cookie } from '@dtinsight/dt-utils';
+import { Cookies } from '@dtinsight/dt-utils';
import { Button, message } from 'antd';
import { useCookieListener } from 'dt-react-component';
export default () => {
useEffect(() => {
- Cookie.deleteCookie('dt_token');
- return () => Cookie.deleteAllCookies('', '');
+ Cookies.remove('dt_token');
+ return () => Cookies.clear();
}, []);
useCookieListener(
@@ -28,7 +28,7 @@ export default () => {