-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
49 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
import React from 'react'; | ||
import { OnScreen } from '../OnScreen'; | ||
import React from "react"; | ||
import { OnScreen } from "../OnScreen"; | ||
import { | ||
ComponentRenderer, | ||
createIsOnScreenValueTest, | ||
createOnceParameterTest, | ||
createRenderTest, | ||
} from './testUtils'; | ||
} from "./testUtils"; | ||
|
||
const renderComponent: ComponentRenderer = (settings) => ( | ||
<OnScreen<HTMLDivElement> {...settings}> | ||
{({ ref, isOnScreen }) => ( | ||
<div ref={ref} data-testid={`target${isOnScreen ? '-isOnScreen' : ''}`} /> | ||
<div ref={ref} data-testid={`target${isOnScreen ? "-isOnScreen" : ""}`} /> | ||
)} | ||
</OnScreen> | ||
); | ||
|
||
describe('OnScreen', () => { | ||
it('OnScreen component renders', createRenderTest(renderComponent)); | ||
describe("OnScreen", () => { | ||
it("OnScreen component renders", createRenderTest(renderComponent)); | ||
|
||
it('isOnScreen value changes', createIsOnScreenValueTest(renderComponent)); | ||
it("isOnScreen value changes", createIsOnScreenValueTest(renderComponent)); | ||
|
||
it('Once prop is working as expected', createOnceParameterTest(renderComponent)); | ||
it("Once prop is working as expected", createOnceParameterTest(renderComponent)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
import React, { useRef } from 'react'; | ||
import { useOnScreen, UseOnScreenParameters } from '../useOnScreen'; | ||
import React, { useRef } from "react"; | ||
import { useOnScreen, UseOnScreenParameters } from "../useOnScreen"; | ||
import { | ||
ComponentRenderer, | ||
createIsOnScreenValueTest, | ||
createOnceParameterTest, | ||
createRenderTest, | ||
} from './testUtils'; | ||
} from "./testUtils"; | ||
|
||
const ComponentTemplate = (props: Pick<UseOnScreenParameters, 'once'>) => { | ||
const ComponentTemplate = (props: Pick<UseOnScreenParameters, "once">) => { | ||
const ref = useRef(null); | ||
const { isOnScreen } = useOnScreen({ ref, ...props }); | ||
|
||
return <div ref={ref} data-testid={`target${isOnScreen ? '-isOnScreen' : ''}`} />; | ||
return <div ref={ref} data-testid={`target${isOnScreen ? "-isOnScreen" : ""}`} />; | ||
}; | ||
|
||
const renderComponent: ComponentRenderer = (settings) => <ComponentTemplate {...settings} />; | ||
|
||
describe('useOnScreen', () => { | ||
it('useOnScreen component renders', createRenderTest(renderComponent)); | ||
describe("useOnScreen", () => { | ||
it("useOnScreen component renders", createRenderTest(renderComponent)); | ||
|
||
it('isOnScreen value changes', createIsOnScreenValueTest(renderComponent)); | ||
it("isOnScreen value changes", createIsOnScreenValueTest(renderComponent)); | ||
|
||
it('Once prop is working as expected', createOnceParameterTest(renderComponent)); | ||
it("Once prop is working as expected", createOnceParameterTest(renderComponent)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export { useOnScreen } from './useOnScreen'; | ||
export type { UseOnScreenParameters } from './useOnScreen'; | ||
export { OnScreen } from './OnScreen'; | ||
export type { OnScreenProps } from './OnScreen'; | ||
export { withOnScreen } from './withOnScreen'; | ||
export type { WithOnScreenWrappedComponent } from './withOnScreen'; | ||
export { useOnScreen } from "./useOnScreen"; | ||
export type { UseOnScreenParameters } from "./useOnScreen"; | ||
export { OnScreen } from "./OnScreen"; | ||
export type { OnScreenProps } from "./OnScreen"; | ||
export { withOnScreen } from "./withOnScreen"; | ||
export type { WithOnScreenWrappedComponent } from "./withOnScreen"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './assignRefs'; | ||
export * from "./assignRefs"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters