-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from add2cal/dev
Dev
- Loading branch information
Showing
8 changed files
with
48 additions
and
20 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import AddToCalendarButton from './AddToCalendarButton'; | ||
import type { AddToCalendarButtonProps } from './AddToCalendarButton'; | ||
import { atcb_action } from 'add-to-calendar-button'; | ||
import type { ATCBActionEventConfig } from 'add-to-calendar-button'; | ||
|
||
export { AddToCalendarButton }; | ||
export { AddToCalendarButton, atcb_action }; | ||
export type AddToCalendarButtonType = AddToCalendarButtonProps; | ||
export type AddToCalendarActionType = ATCBActionEventConfig; |
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,26 +1,41 @@ | ||
import React from 'react'; | ||
import { expect, test } from 'vitest'; | ||
import { render } from '@testing-library/react'; | ||
import { render, waitFor } from '@testing-library/react'; | ||
import { defaultProps } from '../mocks'; | ||
import { AddToCalendarButton } from '../../src/index'; | ||
import { AddToCalendarButton, atcb_action, AddToCalendarButtonType, AddToCalendarActionType } from '../../src/index'; | ||
|
||
test('is imported and mounted', () => { | ||
expect(AddToCalendarButton).toBeTruthy(); | ||
|
||
const component = render(<AddToCalendarButton {...defaultProps} />); | ||
const component = render(<AddToCalendarButton debug {...defaultProps as AddToCalendarButtonType} />); | ||
|
||
expect(component).toBeTruthy(); | ||
expect(component.container.querySelector('add-to-calendar-button')).toBeTruthy(); | ||
}); | ||
|
||
test('is rerendered based on prop', async () => { | ||
const { rerender } = render(<AddToCalendarButton lightMode="dark" {...defaultProps} />); | ||
const { rerender } = render(<AddToCalendarButton debug lightMode="dark" {...defaultProps as AddToCalendarButtonType} />); | ||
|
||
expect(document.querySelector('.atcb-dark')).toBeTruthy(); | ||
expect(document.querySelector('.atcb-light')).toBeFalsy(); | ||
|
||
rerender(<AddToCalendarButton lightMode="light" {...defaultProps} />); | ||
rerender(<AddToCalendarButton lightMode="light" {...defaultProps as AddToCalendarButtonType} />); | ||
|
||
expect(document.querySelector('.atcb-light')).toBeTruthy(); | ||
expect(document.querySelector('.atcb-dark')).toBeFalsy(); | ||
}); | ||
|
||
test('is rendered via atcb_action', async () => { | ||
// create container div | ||
const wrapper = render(<div id="my-container"><button id="my-default-button"></button></div>); | ||
// ... and test for it | ||
const buttonElement = wrapper.container.querySelector('#my-default-button'); | ||
expect(buttonElement).toBeTruthy(); | ||
|
||
// test atcb_action | ||
if (buttonElement) atcb_action(defaultProps as AddToCalendarActionType, buttonElement as HTMLElement); | ||
|
||
await waitFor(() => { | ||
expect(wrapper.container.querySelector('[atcb-button-id="my-default-button"]')).toBeTruthy(); | ||
}); | ||
}); |
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