chore: move use script test
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { renderHook, waitFor } from '@testing-library/react';
|
||||
import { useScript } from './use-script';
|
||||
|
||||
describe('useScript', () => {
|
||||
it('appends a script to the body', async () => {
|
||||
const url = 'http://localhost:8080/foo.js';
|
||||
|
||||
const { result } = renderHook(() => useScript(url));
|
||||
|
||||
expect(result.current).toBe('pending');
|
||||
|
||||
await waitFor(() => {
|
||||
const script = document.body.getElementsByTagName('script')[0];
|
||||
expect(script).toBeInTheDocument();
|
||||
expect(script).toHaveAttribute('src', url);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,24 +1,3 @@
|
||||
import { renderHook, waitFor } from '@testing-library/react';
|
||||
import { useScript } from './trading-view';
|
||||
|
||||
import '@testing-library/jest-dom';
|
||||
|
||||
describe('TradingView', () => {
|
||||
it.todo('should render successfully');
|
||||
});
|
||||
|
||||
describe('useScript', () => {
|
||||
it('appends a script to the body', async () => {
|
||||
const url = 'http://localhost:8080/foo.js';
|
||||
|
||||
const { result } = renderHook(() => useScript(url));
|
||||
|
||||
expect(result.current).toBe(false);
|
||||
|
||||
await waitFor(() => {
|
||||
const script = document.body.getElementsByTagName('script')[0];
|
||||
expect(script).toBeInTheDocument();
|
||||
expect(script).toHaveAttribute('src', url);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -42,7 +42,7 @@ export const TradingView = ({ marketId }: { marketId: string }) => {
|
||||
const datafeed = useDatafeed();
|
||||
|
||||
useEffect(() => {
|
||||
// @ts-ignore cant improt types as chartin_library is external
|
||||
// @ts-ignore cant import types as chartin_library is external
|
||||
// eslint-disable-next-line
|
||||
const widgetOptions: ChartingLibraryWidgetOptions = {
|
||||
symbol: marketId,
|
||||
@@ -50,12 +50,12 @@ export const TradingView = ({ marketId }: { marketId: string }) => {
|
||||
// eslint-disable-next-line
|
||||
|
||||
datafeed,
|
||||
// @ts-ignore cant improt types as chartin_library is external
|
||||
// @ts-ignore cant import types as chartin_library is external
|
||||
interval: '1' as ResolutionString,
|
||||
container: chartContainerRef.current,
|
||||
library_path: 'http://localhost:8080/charting_library/',
|
||||
custom_css_url: '/trading-view-styles.css',
|
||||
// @ts-ignore cant improt types as chartin_library is external
|
||||
// @ts-ignore cant import types as chartin_library is external
|
||||
locale: 'en' as LanguageCode,
|
||||
disabled_features: [
|
||||
'use_localstorage_for_settings',
|
||||
|
||||
Reference in New Issue
Block a user