mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-12-01 05:53:52 +03:00
83b2c19a11
* Update Chrome manifest.json * Remove use of window in background * Test devpanel * Inject pageScript using new API * Keep connection from devpanel to background alive * Keep connection from content script to background alive * Replace page action with action * Cleanup syncOptions * Update options to not rely on background page access * Start work on updating popup * Updates * Remove window * Get opening in a separate window working * Remove pageScriptWrap * Add socket to panelStore * Fix tests * Try to use MV3 for Firefox * Fix path * Fix Chrome E2E tests * Revert unintentional change * Skip Electron tests for now Looks like they're still working through stuff in https://github.com/electron/electron/issues/41613 * Better image centering The Firefox popup did not like the old CSS. This is still not perfect, but it's better than it was. * Create shaggy-taxis-cross.md
89 lines
2.4 KiB
JavaScript
89 lines
2.4 KiB
JavaScript
import { insertScript, listenMessage } from '../../utils/inject';
|
|
import '../../../src/pageScript';
|
|
|
|
describe('API', () => {
|
|
it('should get window.__REDUX_DEVTOOLS_EXTENSION__ function', () => {
|
|
expect(typeof window.__REDUX_DEVTOOLS_EXTENSION__).toBe('function');
|
|
});
|
|
|
|
it('should notify error', () => {
|
|
const mockFunc = jest.fn(() => {});
|
|
window.__REDUX_DEVTOOLS_EXTENSION__.notifyErrors(mockFunc);
|
|
insertScript('hi()');
|
|
expect(mockFunc.mock.calls.length).toBeGreaterThan(0);
|
|
});
|
|
|
|
it('should open monitor', async () => {
|
|
let message = await listenMessage(() => {
|
|
window.__REDUX_DEVTOOLS_EXTENSION__.open();
|
|
});
|
|
expect(message).toEqual({
|
|
source: '@devtools-page',
|
|
type: 'OPEN',
|
|
position: 'window',
|
|
});
|
|
});
|
|
|
|
it('should send message', async () => {
|
|
let message = await listenMessage(() => {
|
|
window.__REDUX_DEVTOOLS_EXTENSION__.send('hi');
|
|
});
|
|
expect(message).toMatchObject({
|
|
type: 'ACTION',
|
|
payload: undefined,
|
|
instanceId: 1,
|
|
name: undefined,
|
|
source: '@devtools-page',
|
|
});
|
|
expect(message.action).toMatch(/{"action":{"type":"hi"},"timestamp":\d+}/);
|
|
|
|
message = await listenMessage(() => {
|
|
window.__REDUX_DEVTOOLS_EXTENSION__.send(
|
|
{ type: 'hi' },
|
|
{ counter: 1 },
|
|
1,
|
|
);
|
|
});
|
|
expect(message).toMatchObject({
|
|
type: 'ACTION',
|
|
payload: '{"counter":1}',
|
|
instanceId: 1,
|
|
name: undefined,
|
|
source: '@devtools-page',
|
|
});
|
|
expect(message.action).toMatch(/{"action":{"type":"hi"},"timestamp":\d+}/);
|
|
|
|
message = await listenMessage(() => {
|
|
window.__REDUX_DEVTOOLS_EXTENSION__.send(
|
|
{ type: 'hi' },
|
|
{ counter: 1 },
|
|
1,
|
|
);
|
|
});
|
|
expect(message).toMatchObject({
|
|
type: 'ACTION',
|
|
payload: '{"counter":1}',
|
|
instanceId: 1,
|
|
name: undefined,
|
|
source: '@devtools-page',
|
|
});
|
|
expect(message.action).toMatch(/{"action":{"type":"hi"},"timestamp":\d+}/);
|
|
|
|
message = await listenMessage(() => {
|
|
window.__REDUX_DEVTOOLS_EXTENSION__.send(undefined, { counter: 1 }, 1);
|
|
});
|
|
expect(message).toEqual({
|
|
action: undefined,
|
|
type: 'STATE',
|
|
payload: { counter: 1 },
|
|
actionsById: undefined,
|
|
computedStates: undefined,
|
|
committedState: false,
|
|
instanceId: 1,
|
|
maxAge: undefined,
|
|
name: undefined,
|
|
source: '@devtools-page',
|
|
});
|
|
});
|
|
});
|