-
Notifications
You must be signed in to change notification settings - Fork 28
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
364 changed files
with
21,615 additions
and
34,408 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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
module.exports = { | ||
root: true, | ||
env: { browser: true, es2020: true }, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:import/recommended', | ||
'plugin:react-hooks/recommended', | ||
"plugin:jest/recommended", | ||
"plugin:jest/style", | ||
"prettier" | ||
], | ||
ignorePatterns: ['dist', '.eslintrc.cjs', 'lib'], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['react-refresh', 'import', 'jest'], | ||
rules: { | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true }, | ||
], | ||
"import/named": "off", | ||
"import/export": "off", | ||
"import/no-unresolved": "off", | ||
"import/prefer-default-export": "off", | ||
"no-unused-expressions": ["warn", { | ||
"allowShortCircuit": true, | ||
"allowTernary": true | ||
}], | ||
"@typescript-eslint/no-unused-vars": "off", | ||
"@typescript-eslint/camelcase": "off", | ||
"@typescript-eslint/prefer-interface": "off", | ||
"@typescript-eslint/explicit-function-return-type": "off", | ||
"@typescript-eslint/explicit-member-accessibility": "off", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/ban-ts-comment": "off", | ||
"react/jsx-filename-extension": "off", | ||
"@typescript-eslint/indent": "off", | ||
"@typescript-eslint/ban-ts-ignore": "off", | ||
"react/prop-types": "off", | ||
"react-hooks/rules-of-hooks": "error", | ||
"react/jsx-uses-react": "off", | ||
"react/react-in-jsx-scope": "off" | ||
}, | ||
settings: { | ||
'import/resolver': { | ||
webpack: { | ||
config: './webpack.prod.js', | ||
}, | ||
}, | ||
}, | ||
} |
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 @@ | ||
16.18.0 | ||
20.15.0 |
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,49 +1,67 @@ | ||
import * as React from 'react'; | ||
import * as TestRenderer from 'react-test-renderer' | ||
import { render, act } from '@testing-library/react'; | ||
import Paragraph from '../src/extensions/paragraph'; | ||
import { setTextSelection } from 'prosemirror-utils'; | ||
import EditMenu from '../src/components/edit-menu'; | ||
import { getEditorViewFromExtensions } from './util'; | ||
|
||
jest.mock('uuid', () => { | ||
return { | ||
v4: jest.fn(() => `test-key-${Math.random().toString(36).substr(2, 9)}`) | ||
}; | ||
}); | ||
|
||
describe('edit-menu', () => { | ||
it('should exist', () => { | ||
const view = getEditorViewFromExtensions([new Paragraph()]); | ||
const editMenu = TestRenderer.create(<EditMenu view={view} menu={[]} />); | ||
const item = editMenu.root.findByProps({ | ||
className: 'smartblock-edit-menu' | ||
}); | ||
const { container } = render(<EditMenu view={view} menu={[]} />); | ||
const item = container.querySelector('.smartblock-edit-menu'); | ||
expect(item).toBeTruthy(); | ||
}); | ||
it('should have proper position style', () => { | ||
const view = getEditorViewFromExtensions([new Paragraph()]); | ||
const editMenu = TestRenderer.create(<EditMenu view={view} menu={[]} />); | ||
const item = editMenu.root.findByProps({ | ||
className: 'smartblock-edit-menu' | ||
}); | ||
expect(item.props.style.top).toBe(0); | ||
TestRenderer.act(() => { | ||
editMenu.update(<EditMenu view={view} menu={[]} />); | ||
}); | ||
// not focused | ||
expect(item.props.style.top).toBe(-1000); | ||
view.dispatch( | ||
setTextSelection(1)( | ||
view.state.tr | ||
) | ||
); | ||
|
||
/* mock view.coordsAtPos */ | ||
view.coordsAtPos = (pos) => ({ | ||
top: 100, | ||
left: 0, | ||
right: 0, | ||
bottom: 0 | ||
}); | ||
|
||
TestRenderer.act(() => { | ||
editMenu.update(<EditMenu view={view} menu={[]} />); | ||
}); | ||
expect(item.props.style.top).not.toBe(0); | ||
expect(item.props.style.top).not.toBe(-1000); | ||
}); | ||
}) | ||
|
||
// it('should have proper position style', () => { | ||
// const view = getEditorViewFromExtensions([new Paragraph()]); | ||
|
||
// // Mock coordsAtPos function | ||
// const mockCoordsAtPos = jest.fn().mockImplementation((pos) => ({ | ||
// top: 100, | ||
// left: 0, | ||
// right: 0, | ||
// bottom: 0 | ||
// })); | ||
|
||
// const { container, rerender } = render(<EditMenu view={view} menu={[]} />); | ||
// const item = container.querySelector<HTMLDivElement>('.smartblock-edit-menu') as HTMLDivElement; | ||
// expect(item).toBeTruthy(); | ||
// expect(item.style.top).toBe('0px'); | ||
|
||
// act(() => { | ||
// rerender(<EditMenu view={view} menu={[]} />); | ||
// }); | ||
|
||
// // not focused | ||
// expect(item.style.top).toBe('-1000px'); | ||
|
||
// act(() => { | ||
// view.dispatch( | ||
// setTextSelection(1)( | ||
// view.state.tr | ||
// ) | ||
// ); | ||
// }); | ||
|
||
|
||
|
||
// act(() => { | ||
// view.coordsAtPos = mockCoordsAtPos; | ||
|
||
// rerender(<EditMenu view={view} menu={[]} />); | ||
// }); | ||
|
||
// // Verify that the mock function was called | ||
// expect(mockCoordsAtPos).toHaveBeenCalled(); | ||
|
||
// expect(item.style.top).not.toBe('0px'); | ||
// expect(item.style.top).not.toBe('-1000px'); | ||
// }); | ||
}); |
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
Oops, something went wrong.