use-upbit-api
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -10,2 +10,3 @@ "use strict"; | ||
const socketDataEncoder_1 = __importDefault(require("../functions/socketDataEncoder")); | ||
const isImarketCodes_1 = __importDefault(require("../functions/isImarketCodes")); | ||
// extend extend OptionsInterface | ||
@@ -40,7 +41,5 @@ /** | ||
try { | ||
// if (targetMarketCodes && !isImarketCodes(targetMarketCodes)) { | ||
// throw new Error( | ||
// 'targetMarketCodes does not have the correct interface', | ||
// ); | ||
// } | ||
if (targetMarketCodes && !(0, isImarketCodes_1.default)(targetMarketCodes)) { | ||
throw new Error('targetMarketCodes does not have the correct interface'); | ||
} | ||
if ([targetMarketCodes].length > 0 && !socket.current) { | ||
@@ -47,0 +46,0 @@ socket.current = new WebSocket(SOCKET_URL); |
@@ -12,3 +12,3 @@ "use strict"; | ||
const updateSocketData_1 = __importDefault(require("../functions/updateSocketData")); | ||
// import isArrayOfImarketCodes from '../functions/isArrayOfImarketCodes'; | ||
const isArrayOfImarketCodes_1 = __importDefault(require("../functions/isArrayOfImarketCodes")); | ||
/** | ||
@@ -45,10 +45,6 @@ * useWsTicker is a custom hook that connects to a WebSocket API | ||
try { | ||
// if ( | ||
// targetMarketCodes.length > 0 && | ||
// !isArrayOfImarketCodes(targetMarketCodes) | ||
// ) { | ||
// throw new Error( | ||
// 'targetMarketCodes does not have the correct interface', | ||
// ); | ||
// } | ||
if (targetMarketCodes.length > 0 && | ||
!(0, isArrayOfImarketCodes_1.default)(targetMarketCodes)) { | ||
throw new Error('targetMarketCodes does not have the correct interface'); | ||
} | ||
if (targetMarketCodes.length > 0 && !socket.current) { | ||
@@ -89,3 +85,4 @@ socket.current = new WebSocket(SOCKET_URL); | ||
const data = (0, socketDataEncoder_1.default)(evt.data); | ||
console.log('data:', data); | ||
if (debug) | ||
console.log('data:', data); | ||
data && buffer.current.push(data); | ||
@@ -92,0 +89,0 @@ throttled(); |
@@ -10,2 +10,3 @@ "use strict"; | ||
const socketDataEncoder_1 = __importDefault(require("../functions/socketDataEncoder")); | ||
const isImarketCodes_1 = __importDefault(require("../functions/isImarketCodes")); | ||
/** | ||
@@ -40,7 +41,5 @@ * useWsTrade is a custom hook that connects to a WebSocket API | ||
try { | ||
// if (targetMarketCodes && !isImarketCodes(targetMarketCodes)) { | ||
// throw new Error( | ||
// 'targetMarketCodes does not have the correct interface', | ||
// ); | ||
// } | ||
if (targetMarketCodes && !(0, isImarketCodes_1.default)(targetMarketCodes)) { | ||
throw new Error('targetMarketCodes does not have the correct interface'); | ||
} | ||
if ([targetMarketCodes].length > 0 && !socket.current) { | ||
@@ -47,0 +46,0 @@ socket.current = new WebSocket(SOCKET_URL); |
@@ -44,3 +44,2 @@ "use strict"; | ||
require("@testing-library/jest-dom/extend-expect"); | ||
// import ErrorBoundary from './ErrorBoundary'; | ||
const debugTest = false; | ||
@@ -70,23 +69,2 @@ const TestOrderbookComponent = ({ customMarketCode, onError, }) => { | ||
describe('useWsOrderbook hook', () => { | ||
// Test invalid targetMarketCodes | ||
// it('useWsOrderbook should throw error with invalid targetMarketCodes', () => { | ||
// const onError: jest.MockedFunction<(error: Error) => void> = jest.fn(); | ||
// const invalidTargetMarketCodes = { | ||
// market: 'test_market', | ||
// korean_name: 'test_korean', | ||
// }; | ||
// // Render the TestOrderbookComponent | ||
// render( | ||
// <ErrorBoundary onError={onError}> | ||
// <TestOrderbookComponent | ||
// customMarketCode={invalidTargetMarketCodes} | ||
// onError={onError} | ||
// /> | ||
// </ErrorBoundary>, | ||
// ); | ||
// expect(onError).toHaveBeenCalled(); | ||
// expect(onError.mock.calls[0][0].message).toBe( | ||
// 'targetMarketCodes does not have the correct interface', | ||
// ); | ||
// }); | ||
it('received socket data correctly', () => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -93,0 +71,0 @@ // Render the TestOrderbookComponent |
@@ -43,2 +43,3 @@ "use strict"; | ||
require("@testing-library/jest-dom/extend-expect"); | ||
const ErrorBoundary_1 = __importDefault(require("./ErrorBoundary")); | ||
const debugTest = false; | ||
@@ -75,29 +76,21 @@ const TestTickerComponent = ({ customMarketCode, onError, }) => { | ||
// Test invalid targetMarketCodes | ||
// it('useWsTicker should throw error with invalid targetMarketCodes', () => { | ||
// const onError: jest.MockedFunction<(error: Error) => void> = jest.fn(); | ||
// const invalidTargetMarketCodes = [ | ||
// { | ||
// market: 'KRW-BTC', | ||
// korean_name: '비트코인', | ||
// english_name: 'Bitcoin', | ||
// }, | ||
// { | ||
// market: 'KRW-ETH', | ||
// korean_name: '이더리움', | ||
// }, | ||
// ]; | ||
// // Render the TestOrderbookComponent | ||
// render( | ||
// <ErrorBoundary onError={onError}> | ||
// <TestTickerComponent | ||
// customMarketCode={invalidTargetMarketCodes} | ||
// onError={onError} | ||
// /> | ||
// </ErrorBoundary>, | ||
// ); | ||
// expect(onError).toHaveBeenCalled(); | ||
// expect(onError.mock.calls[0][0].message).toBe( | ||
// 'targetMarketCodes does not have the correct interface', | ||
// ); | ||
// }); | ||
it('useWsTicker should throw error with invalid targetMarketCodes', () => { | ||
const onError = jest.fn(); | ||
const invalidTargetMarketCodes = [ | ||
{ | ||
market: 'KRW-BTC', | ||
korean_name: '비트코인', | ||
english_name: 'Bitcoin', | ||
}, | ||
{ | ||
market: 'KRW-ETH', | ||
korean_name: '이더리움', | ||
}, | ||
]; | ||
// Render the TestOrderbookComponent | ||
(0, react_2.render)(React.createElement(ErrorBoundary_1.default, { onError: onError }, | ||
React.createElement(TestTickerComponent, { customMarketCode: invalidTargetMarketCodes, onError: onError }))); | ||
expect(onError).toHaveBeenCalled(); | ||
expect(onError.mock.calls[0][0].message).toBe('targetMarketCodes does not have the correct interface'); | ||
}); | ||
it('renders connection status and received socket data', () => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -104,0 +97,0 @@ // Render the TestTickerComponent |
@@ -45,3 +45,2 @@ "use strict"; | ||
const react_3 = require("react"); | ||
// import ErrorBoundary from './ErrorBoundary'; | ||
const debugTest = false; | ||
@@ -71,23 +70,2 @@ const TestTradeComponent = ({ customMarketCode, onError, }) => { | ||
describe('useWsTrade hook', () => { | ||
// Test invalid targetMarketCodes | ||
// it('useWsTrade should throw error with invalid targetMarketCodes', () => { | ||
// const onError: jest.MockedFunction<(error: Error) => void> = jest.fn(); | ||
// const invalidTargetMarketCodes = { | ||
// market: 'test_market', | ||
// korean_name: 'test_korean', | ||
// }; | ||
// // Render the TestTradeComponent | ||
// render( | ||
// <ErrorBoundary onError={onError}> | ||
// <TestTradeComponent | ||
// customMarketCode={invalidTargetMarketCodes} | ||
// onError={onError} | ||
// /> | ||
// </ErrorBoundary>, | ||
// ); | ||
// expect(onError).toHaveBeenCalled(); | ||
// expect(onError.mock.calls[0][0].message).toBe( | ||
// 'targetMarketCodes does not have the correct interface', | ||
// ); | ||
// }); | ||
it('renders connection status and received socket data', () => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -94,0 +72,0 @@ // Render the TestTradeComponent |
{ | ||
"name": "use-upbit-api", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "This is React Custom Hook for upbit api", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -120,7 +120,7 @@ # use-upbit-api | ||
2. You want to **implement a feature or bug-fix** for an outstanding issue. | ||
- Search for your issue in the [Mips-simulator-js issue list](https://github.com/devKangMinHyeok/use-upbit-api/issues). | ||
- Search for your issue in the [use-upbit-api issue list](https://github.com/devKangMinHyeok/use-upbit-api/issues). | ||
- Pick an issue and comment that you'd like to work on the feature or bug-fix. | ||
- If you need more context on a particular issue, please ask and we shall provide. | ||
3. **Open pull request** | ||
- You implement and test your feature or bug-fix, please submit a Pull Request to [https://github.com/mipsSimulatorUNIST/simulator/pulls](https://github.com/devKangMinHyeok/use-upbit-api/pulls) with some test case. | ||
- You implement and test your feature or bug-fix, please submit a Pull Request to [use-upbit-api PR](https://github.com/devKangMinHyeok/use-upbit-api/pulls) with some test case. | ||
- Once a pull request is accepted and CI is passing, there is nothing else you need to do. we will check and merge the PR for you. | ||
@@ -127,0 +127,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76393
1565