Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(logs): button update time format (#404)
- Loading branch information
1 parent
b4f8e29
commit 0968851
Showing
9 changed files
with
152 additions
and
24 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
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
51 changes: 51 additions & 0 deletions
51
...i/src/lib/components/layouts/layout-logs/update-time-context/update-time-context.spec.tsx
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { fireEvent, getByRole, render } from '@testing-library/react' | ||
import { useContext } from 'react' | ||
import { UpdateTimeContext } from './update-time-context' | ||
|
||
const setUpdateTime = jest.fn() | ||
|
||
function Content() { | ||
const { utc, setUpdateTimeContext } = useContext(UpdateTimeContext) | ||
|
||
return ( | ||
<div> | ||
<button onClick={() => setUpdateTimeContext && setUpdateTimeContext({ utc: true })}> | ||
Click {utc.toString()} | ||
</button> | ||
</div> | ||
) | ||
} | ||
|
||
describe('UpdateTimeContext', () => { | ||
it('should render successfully', () => { | ||
const { baseElement } = render( | ||
<UpdateTimeContext.Provider | ||
value={{ | ||
...{ utc: false }, | ||
setUpdateTimeContext: setUpdateTime, | ||
}} | ||
> | ||
<Content /> | ||
</UpdateTimeContext.Provider> | ||
) | ||
expect(baseElement).toBeTruthy() | ||
}) | ||
|
||
it('should change context UTC boolean', async () => { | ||
const { baseElement } = render( | ||
<UpdateTimeContext.Provider | ||
value={{ | ||
...{ utc: false }, | ||
setUpdateTimeContext: setUpdateTime, | ||
}} | ||
> | ||
<Content /> | ||
</UpdateTimeContext.Provider> | ||
) | ||
|
||
const button = getByRole(baseElement, 'button') | ||
fireEvent.click(button) | ||
|
||
expect(baseElement.textContent).toBe('Click false') | ||
}) | ||
}) |
12 changes: 12 additions & 0 deletions
12
...red/ui/src/lib/components/layouts/layout-logs/update-time-context/update-time-context.tsx
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { createContext } from 'react' | ||
|
||
interface UpdateTimeContextProps { | ||
utc: boolean | ||
setUpdateTimeContext?: (data: { utc: boolean }) => void | ||
} | ||
|
||
export const defaultUpdateTimeContext = { | ||
utc: false, | ||
} | ||
|
||
export const UpdateTimeContext = createContext<UpdateTimeContextProps>(defaultUpdateTimeContext) |
19 changes: 4 additions & 15 deletions
19
libs/shared/ui/src/lib/components/modal/modal-root.spec.tsx
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