Skip to content

Commit 9a1e597

Browse files
committed
dependencies: add typescript support
1 parent f438845 commit 9a1e597

File tree

74 files changed

+2891
-2411
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+2891
-2411
lines changed

.eslintrc

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"parser": "@babel/eslint-parser",
2+
"parser": "@typescript-eslint/parser",
33
"parserOptions": {
4-
"ecmaVersion": 6,
4+
"ecmaVersion": 2020,
55
"sourceType": "module",
6-
"requireConfigFile": false,
76
"ecmaFeatures": {
8-
"experimentalObjectRestSpread": true
9-
}
7+
"jsx": true
8+
},
9+
"project": "./tsconfig.json"
1010
},
1111
"env": {
1212
"browser": true,
@@ -21,10 +21,12 @@
2121
"plugin:jsx-a11y/recommended",
2222
"plugin:react/recommended",
2323
"plugin:import/recommended",
24+
"plugin:import/typescript",
2425
"plugin:n/recommended",
2526
"plugin:react-hooks/recommended",
26-
"plugin:promise/recommended"
27-
],
27+
"plugin:promise/recommended",
28+
"plugin:@typescript-eslint/recommended"
29+
],
2830
"rules": {
2931
"jsx-quotes": [2, "prefer-double"],
3032
"jsx-a11y/no-onchange": "off",
@@ -34,24 +36,50 @@
3436
"n/no-missing-import": "off",
3537
"n/no-unpublished-import": "off",
3638
"n/no-extraneous-import": "off",
37-
"no-restricted-syntax": ["error", "TemplateLiteral"]
39+
"no-restricted-syntax": ["error", "TemplateLiteral"],
40+
"import/default": "warn",
41+
// TypeScript specific rules
42+
"@typescript-eslint/explicit-function-return-type": "off",
43+
"@typescript-eslint/explicit-module-boundary-types": "off",
44+
"@typescript-eslint/no-explicit-any": "warn",
45+
"@typescript-eslint/no-this-alias": "warn",
46+
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
47+
"@typescript-eslint/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }]
3848
},
3949
"plugins": [
4050
"jsx-a11y",
4151
"jest",
42-
"promise"
52+
"promise",
53+
"@typescript-eslint"
4354
],
4455
"ignorePatterns": [
4556
"node_modules/",
46-
"venv/"
57+
"venv/",
58+
"*.d.ts"
4759
],
4860
"settings": {
49-
"import/core-modules": [ django ],
61+
"import/core-modules": ["django"],
5062
"import/resolver": {
5163
"node": {
52-
"extensions": [".js", ".jsx"]
64+
"extensions": [".js", ".jsx", ".ts", ".tsx"],
65+
"paths": ["src"]
66+
},
67+
"typescript": {
68+
"alwaysTryTypes": true,
69+
"project": "./tsconfig.json"
70+
}
71+
},
72+
"react": {
73+
"version": "detect"
74+
}
75+
},
76+
"overrides": [
77+
{
78+
"files": ["*.js", "*.jsx"],
79+
"rules": {
80+
"@typescript-eslint/explicit-function-return-type": "off",
81+
"@typescript-eslint/no-var-requires": "off"
5382
}
5483
}
55-
}
56-
}
57-
84+
]
85+
}

__mocks__/djangoMock.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

__mocks__/flipmoveMock.js

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,33 @@
11
import React from 'react'
22
import { render, fireEvent, screen } from '@testing-library/react'
3-
import '@testing-library/jest-dom'
4-
import AiReport from '../ai_report'
3+
import { describe, test, expect } from 'vitest' // Import from vitest
54

5+
import AiReport from '../ai_report'
66
describe('Test AiReport', () => {
7+
const testReport = {
8+
label: [['cattest', 'test label']],
9+
confidence: [['cattest', 0.65]],
10+
explanation: { cattest: [['word', 0.61]] },
11+
show_in_discussion: true
12+
}
13+
714
test('renders with Read More button', () => {
8-
render(
9-
<AiReport
10-
report={{ label: [['cattest', 'test label']], confidence: [['cattest', 0.65]], explanation: { cattest: [['word', 0.61]] }, show_in_discussion: true }}
11-
/>
12-
)
13-
const comment = screen.getByText('Read more')
14-
expect(comment).toBeInTheDocument()
15+
render(<AiReport report={testReport} />)
16+
expect(screen.getByText('Read more')).toBeInTheDocument()
1517
})
1618

17-
test('functionality of Read More button', () => {
18-
render(
19-
<AiReport
20-
report={{ label: [['cattest', 'test label']], confidence: [['cattest', 0.65]], explanation: { cattest: [['word', 0.61]] }, show_in_discussion: true }}
21-
/>
22-
)
23-
const readMore = screen.getByText('Read more')
24-
expect(readMore).toBeInTheDocument()
19+
test('functionality of Read More button', async () => {
20+
render(<AiReport report={testReport} />)
2521
const button = screen.getByRole('button')
26-
expect(button).toBeInTheDocument()
2722
fireEvent.click(button)
28-
const readLess = screen.getByText('Show less')
29-
expect(readLess).toBeInTheDocument()
30-
expect(readLess).toBeInTheDocument()
23+
const showLessButton = screen.getByText("Show less")
24+
await expect(showLessButton).toHaveTextContent("Show less")
3125
})
3226

33-
test('shows percentage for each label', async () => {
34-
render(
35-
<AiReport
36-
report={{ label: [['cattest', 'test label']], confidence: [0.65], explanation: { cattest: [['word', 0.61]] }, show_in_discussion: true }}
37-
/>
38-
)
39-
const readMore = screen.getByText('Read more')
40-
expect(readMore).toBeInTheDocument()
27+
test('shows percentage for each label', () => {
28+
render(<AiReport report={{...testReport, confidence: [0.65]}} />)
4129
const button = screen.getByRole('button')
42-
expect(button).toBeInTheDocument()
4330
fireEvent.click(button)
44-
const percent = screen.getByText(/65%/)
45-
expect(percent).toBeInTheDocument()
31+
expect(screen.getByText(/65%/)).toBeInTheDocument()
4632
})
47-
})
33+
})

adhocracy4/comments_async/static/comments_async/__tests__/__snapshots__/comment.jest.jsx.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`Comment Component renders comment with creator and comment text 1`] = `
3+
exports[`Comment Component > renders comment with creator and comment text 1`] = `
44
{
55
"asFragment": [Function],
66
"baseElement": <body>
@@ -219,7 +219,7 @@ exports[`Comment Component renders comment with creator and comment text 1`] = `
219219
id="share-url-undefined"
220220
readonly=""
221221
type="text"
222-
value="http://localhost/?comment=1"
222+
value="http://localhost:3000/?comment=1"
223223
/>
224224
<button
225225
aria-pressed="false"
@@ -465,7 +465,7 @@ exports[`Comment Component renders comment with creator and comment text 1`] = `
465465
}
466466
`;
467467

468-
exports[`Comment Component renders comment with moderator badge 1`] = `
468+
exports[`Comment Component > renders comment with moderator badge 1`] = `
469469
{
470470
"asFragment": [Function],
471471
"baseElement": <body>
@@ -689,7 +689,7 @@ exports[`Comment Component renders comment with moderator badge 1`] = `
689689
id="share-url-undefined"
690690
readonly=""
691691
type="text"
692-
value="http://localhost/?comment=1"
692+
value="http://localhost:3000/?comment=1"
693693
/>
694694
<button
695695
aria-pressed="false"

0 commit comments

Comments
 (0)