Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fcollonval committed Oct 22, 2023
1 parent a4466b5 commit 4b80f30
Show file tree
Hide file tree
Showing 29 changed files with 1,114 additions and 1,246 deletions.
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const esModules = [
'@jupyterlab/',
'lib0',
'nanoid',
'nbdime',
'vscode-ws-jsonrpc',
'y-protocols',
'y-websocket',
Expand All @@ -30,6 +31,8 @@ module.exports = {
'<rootDir>/jupyter-config',
'<rootDir>/ui-tests'
],
reporters: ['default', 'github-actions'],
setupFiles: ['<rootDir>/testutils/jest-setup-files.js'],
testRegex: 'src/.*/.*.spec.ts[x]?$',
transformIgnorePatterns: [`/node_modules/(?!${esModules}).+`]
};
1 change: 1 addition & 0 deletions jupyterlab_git/tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ async def test_all_history_handler_localbranch(mock_git, jp_fetch, jp_root_dir):
mock_git.status.return_value = maybe_future(status)

# When
body = {"history_count": 25}
response = await jp_fetch(
NAMESPACE, local_path.name, "all_history", body=json.dumps(body), method="POST"
)
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@
"@babel/preset-env": "^7.0.0",
"@jupyterlab/builder": "^4.0.0",
"@jupyterlab/testutils": "^4.0.0",
"@testing-library/jest-dom": "^6.1.4",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.5.1",
"@types/diff-match-patch": "^1.0.32",
"@types/enzyme": "^3.1.15",
"@types/jest": "^29.2.0",
"@types/json-schema": "^7.0.11",
"@types/react": "^18.0.26",
Expand All @@ -114,10 +116,8 @@
"@types/resize-observer-browser": "^0.1.7",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
"all-contributors-cli": "^6.14.0",
"css-loader": "^6.7.1",
"enzyme": "^3.7.0",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^5.0.0",
Expand All @@ -126,11 +126,11 @@
"husky": "^8.0.3",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.2.0",
"jest-fetch-mock": "^3.0.0",
"lint-staged": "^13.2.3",
"mkdirp": "^1.0.3",
"npm-run-all": "^4.1.5",
"prettier": "^3.0.0",
"resize-observer-polyfill": "^1.5.1",
"rimraf": "^5.0.1",
"source-map-loader": "^1.0.2",
"style-loader": "^3.3.1",
Expand All @@ -139,7 +139,7 @@
"stylelint-config-standard": "^34.0.0",
"stylelint-csstree-validator": "^3.0.0",
"stylelint-prettier": "^4.0.0",
"ts-jest": "^26.0.0",
"ts-jest": "^29.1.0",
"typescript": "~5.0.2",
"yjs": "^13.5.40"
},
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/model.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('IGitExtension', () => {
responses: { ...defaultMockedResponses }
};

mockGit.requestAPI.mockImplementation(mockedRequestAPI(mockResponses));
mockGit.requestAPI.mockImplementation(mockedRequestAPI(mockResponses) as any);

model = new GitExtension(docmanager as any, docregistry as any);
});
Expand Down
16 changes: 9 additions & 7 deletions src/__tests__/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,23 @@ describe('plugin', () => {
}
} as unknown as jest.Mocked<IFileBrowserFactory>;
settingRegistry = new SettingRegistry({
connector: null
}) as jest.Mocked<SettingRegistry>;
connector: null as any
}) as any;
});

beforeEach(() => {
jest.resetAllMocks();
mockResponses = { responses: { ...defaultMockedResponses } };
mockGit.requestAPI.mockImplementation(mockedRequestAPI(mockResponses));
mockGit.requestAPI.mockImplementation(
mockedRequestAPI(mockResponses) as any
);
});

describe('#activate', () => {
it('should fail if no git is installed', async () => {
// Given
const endpoint = 'settings' + URLExt.objectToQueryString({ version });
mockResponses.responses[endpoint] = {
mockResponses.responses![endpoint] = {
body: request => {
return {
gitVersion: null,
Expand Down Expand Up @@ -85,7 +87,7 @@ describe('plugin', () => {
it('should fail if git version is < 2', async () => {
// Given
const endpoint = 'settings' + URLExt.objectToQueryString({ version });
mockResponses.responses[endpoint] = {
mockResponses.responses![endpoint] = {
body: request => {
return {
gitVersion: '1.8.7',
Expand Down Expand Up @@ -119,7 +121,7 @@ describe('plugin', () => {
it('should fail if server and extension version do not match', async () => {
// Given
const endpoint = 'settings' + URLExt.objectToQueryString({ version });
mockResponses.responses[endpoint] = {
mockResponses.responses![endpoint] = {
body: request => {
return {
gitVersion: '2.22.0',
Expand Down Expand Up @@ -156,7 +158,7 @@ describe('plugin', () => {
it('should fail if the server extension is not installed', async () => {
// Given
const endpoint = 'settings' + URLExt.objectToQueryString({ version });
mockResponses.responses[endpoint] = {
mockResponses.responses![endpoint] = {
status: 404
};
const mockedErrorMessage = showErrorMessage as jest.MockedFunction<
Expand Down
Loading

0 comments on commit 4b80f30

Please sign in to comment.