-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat(api): added deactivateCallback * feat(api): added tests for deactivateCallback * feat(api): refactoring after review * feat(api): refactoring of dismissCallback
- Loading branch information
Showing
5 changed files
with
72 additions
and
19 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
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,46 @@ | ||
import { fireEvent } from '@testing-library/dom' | ||
import { | ||
setDocumentBody, | ||
getPopover, | ||
waitToStopChanging, | ||
getButton, | ||
} from '../helper' | ||
import littlefoot from '../../src' | ||
|
||
test('setup with dismissCallback', async () => { | ||
setDocumentBody('single.html') | ||
const dismissCallback = jest.fn() | ||
littlefoot({ dismissCallback: dismissCallback }) | ||
|
||
const button = getButton('1') | ||
|
||
fireEvent.click(button) | ||
await waitToStopChanging(button) | ||
|
||
fireEvent.click(button) | ||
const popover = getPopover('1') | ||
await waitToStopChanging(button) | ||
|
||
expect(dismissCallback).toHaveBeenCalledTimes(1) | ||
expect(dismissCallback).toHaveBeenCalledWith(popover, button) | ||
}) | ||
|
||
test('dismissCallback can be set after initialisation', async () => { | ||
setDocumentBody('single.html') | ||
const dismissCallback = jest.fn() | ||
|
||
const instance = littlefoot() | ||
instance.updateSetting('dismissCallback', dismissCallback) | ||
|
||
const button = getButton('1') | ||
|
||
fireEvent.click(button) | ||
await waitToStopChanging(button) | ||
|
||
fireEvent.click(button) | ||
const popover = getPopover('1') | ||
await waitToStopChanging(button) | ||
|
||
expect(dismissCallback).toHaveBeenCalledTimes(1) | ||
expect(dismissCallback).toHaveBeenCalledWith(popover, button) | ||
}) |