mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-21 09:38:01 +02:00
Tools: Add more eslint/jest rules
This commit is contained in:
parent
3eca4ada5a
commit
99c6c9b411
@ -92,6 +92,8 @@ module.exports = {
|
||||
// "react-hooks/exhaustive-deps": "warn",
|
||||
|
||||
'jest/require-top-level-describe': ['error', { 'maxNumberOfTopLevelDescribes': 1 }],
|
||||
'jest/no-identical-title': ['error'],
|
||||
'jest/prefer-lowercase-title': ['error', { 'ignoreTopLevelDescribe': true }],
|
||||
|
||||
'promise/prefer-await-to-then': 'error',
|
||||
'no-unneeded-ternary': 'error',
|
||||
|
@ -3,7 +3,7 @@ import appReducer, { createAppDefaultState } from './app.reducer';
|
||||
|
||||
describe('app.reducer', () => {
|
||||
|
||||
it('DIALOG_OPEN', async () => {
|
||||
it('should handle DIALOG_OPEN', async () => {
|
||||
const state: AppState = createAppDefaultState({}, {});
|
||||
|
||||
let newState = appReducer(state, {
|
||||
|
@ -147,7 +147,7 @@ describe('movements', () => {
|
||||
expect(canMove(MoveDirection.Right, findItemByKey(layout, 'col2'), findItemByKey(layout, 'root'))).toBe(false);
|
||||
});
|
||||
|
||||
test('Container with only one child should take the width of its parent', () => {
|
||||
test('container with only one child should take the width of its parent', () => {
|
||||
let layout: LayoutItem = validateLayout({
|
||||
key: 'root',
|
||||
width: 100,
|
||||
@ -170,7 +170,7 @@ describe('movements', () => {
|
||||
expect(layout.children[0].children[0].width).toBe(undefined);
|
||||
});
|
||||
|
||||
test('Temp container should take the width of the child it replaces', () => {
|
||||
test('temp container should take the width of the child it replaces', () => {
|
||||
let layout: LayoutItem = validateLayout({
|
||||
key: 'root',
|
||||
width: 100,
|
||||
@ -198,7 +198,7 @@ describe('movements', () => {
|
||||
expect(layout.children[0].children[1].width).toBe(undefined);
|
||||
});
|
||||
|
||||
test('Last child should have flexible width if all siblings have fixed width', () => {
|
||||
test('last child should have flexible width if all siblings have fixed width', () => {
|
||||
let layout: LayoutItem = validateLayout({
|
||||
key: 'root',
|
||||
width: 100,
|
||||
|
@ -239,17 +239,5 @@ describe('markdownCommands', () => {
|
||||
expect(sel.from).toBe('> Testing...> \n> \n'.length);
|
||||
expect(sel.to).toBe(editor.state.doc.length);
|
||||
});
|
||||
|
||||
it('toggling inline code should both create and navigate out of an inline code region', async () => {
|
||||
const initialDocText = 'Testing...\n\n';
|
||||
const editor = await createEditor(initialDocText, EditorSelection.cursor(initialDocText.length), []);
|
||||
|
||||
toggleCode(editor);
|
||||
editor.dispatch(editor.state.replaceSelection('f(x) = ...'));
|
||||
toggleCode(editor);
|
||||
|
||||
editor.dispatch(editor.state.replaceSelection(' is a function.'));
|
||||
expect(editor.state.doc.toString()).toBe('Testing...\n\n`f(x) = ...` is a function.');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -25,12 +25,12 @@ const testCases: testCase[] = [
|
||||
|
||||
describe('getResponsiveValue', () => {
|
||||
|
||||
test('Should throw exception if value map is an empty object', () => {
|
||||
test('should throw exception if value map is an empty object', () => {
|
||||
const input = {};
|
||||
expect(() => getResponsiveValue(input)).toThrow('valueMap cannot be an empty object!');
|
||||
});
|
||||
|
||||
test('Should return correct values', () => {
|
||||
test('should return correct values', () => {
|
||||
const mockReturnValues = [
|
||||
{ width: 400 },
|
||||
{ width: 480 },
|
||||
|
@ -413,28 +413,28 @@ describe('models/Note', () => {
|
||||
expect(Note['replaceResourceExternalToInternalLinks_'](pathsToTry, body)).toBe(expected);
|
||||
}
|
||||
|
||||
test('Basic replacement', () => {
|
||||
test('basic replacement', () => {
|
||||
const body = '![image.png](file:///C:Users/Username/resources/849eae4dade045298c107fc706b6d2bc.png?t=1655192326803)';
|
||||
const pathsToTry = ['file:///C:Users/Username/resources'];
|
||||
const expected = '![image.png](:/849eae4dade045298c107fc706b6d2bc)';
|
||||
testResourceReplacment(body, pathsToTry, expected);
|
||||
});
|
||||
|
||||
test('Replacement with spaces', () => {
|
||||
test('replacement with spaces', () => {
|
||||
const body = '![image.png](file:///C:Users/Username%20with%20spaces/resources/849eae4dade045298c107fc706b6d2bc.png?t=1655192326803)';
|
||||
const pathsToTry = ['file:///C:Users/Username with spaces/resources'];
|
||||
const expected = '![image.png](:/849eae4dade045298c107fc706b6d2bc)';
|
||||
testResourceReplacment(body, pathsToTry, expected);
|
||||
});
|
||||
|
||||
test('Replacement with Non-ASCII', () => {
|
||||
test('replacement with Non-ASCII', () => {
|
||||
const body = '![image.png](file:///C:Users/UsernameWith%C3%A9%C3%A0%C3%B6/resources/849eae4dade045298c107fc706b6d2bc.png?t=1655192326803)';
|
||||
const pathsToTry = ['file:///C:Users/UsernameWithéàö/resources'];
|
||||
const expected = '![image.png](:/849eae4dade045298c107fc706b6d2bc)';
|
||||
testResourceReplacment(body, pathsToTry, expected);
|
||||
});
|
||||
|
||||
test('Replacement with Non-ASCII and spaces', () => {
|
||||
test('replacement with Non-ASCII and spaces', () => {
|
||||
const body = '![image.png](file:///C:Users/Username%20With%20%C3%A9%C3%A0%C3%B6/resources/849eae4dade045298c107fc706b6d2bc.png?t=1655192326803)';
|
||||
const pathsToTry = ['file:///C:Users/Username With éàö/resources'];
|
||||
const expected = '![image.png](:/849eae4dade045298c107fc706b6d2bc)';
|
||||
|
@ -66,7 +66,7 @@ describe('services_SearchFilter', () => {
|
||||
for (const searchType of [SearchEngine.SEARCH_TYPE_FTS, SearchEngine.SEARCH_TYPE_NONLATIN_SCRIPT]) {
|
||||
|
||||
describe(`search type ${searchType}`, () => {
|
||||
it('Check case insensitivity for filter keywords', (async () => {
|
||||
it('check case insensitivity for filter keywords', (async () => {
|
||||
let rows;
|
||||
const notebook1 = await Folder.save({ title: 'folderA' });
|
||||
const notebook2 = await Folder.save({ title: 'folderB' });
|
||||
@ -311,7 +311,7 @@ describe('services_SearchFilter', () => {
|
||||
}));
|
||||
|
||||
|
||||
it('should support filtering by tags', (async () => {
|
||||
it('should support filtering by tags (2)', (async () => {
|
||||
let rows;
|
||||
const n1 = await Note.save({ title: 'peace talks', body: 'battle ground' });
|
||||
const n2 = await Note.save({ title: 'mouse', body: 'mister' });
|
||||
|
@ -22,7 +22,7 @@ function loadFile(filePath: string) {
|
||||
|
||||
describe('pdfData', () => {
|
||||
|
||||
test('Should have correct page count', async () => {
|
||||
test('should have correct page count', async () => {
|
||||
const file = await loadFile(pdfFilePath1);
|
||||
const pdf = new PdfDocument(document);
|
||||
await pdf.loadDoc(file);
|
||||
@ -39,7 +39,7 @@ describe('pdfData', () => {
|
||||
// }).rejects.toThrowError();
|
||||
// });
|
||||
|
||||
test('Should get correct page size', async () => {
|
||||
test('should get correct page size', async () => {
|
||||
const file = await loadFile(pdfFilePath1);
|
||||
const pdf = new PdfDocument(document);
|
||||
await pdf.loadDoc(file);
|
||||
@ -48,7 +48,7 @@ describe('pdfData', () => {
|
||||
expect(size.width).toBeCloseTo(594.95996);
|
||||
});
|
||||
|
||||
test('Should calculate scaled size', async () => {
|
||||
test('should calculate scaled size', async () => {
|
||||
const file = await loadFile(pdfFilePath1);
|
||||
const pdf = new PdfDocument(document);
|
||||
await pdf.loadDoc(file);
|
||||
@ -56,7 +56,7 @@ describe('pdfData', () => {
|
||||
expect(scaledSize.scale).toBeCloseTo(0.336157);
|
||||
});
|
||||
|
||||
test('Should get correct active page', async () => {
|
||||
test('should get correct active page', async () => {
|
||||
const file = await loadFile(pdfFilePath1);
|
||||
const pdf = new PdfDocument(document);
|
||||
await pdf.loadDoc(file);
|
||||
|
@ -237,35 +237,6 @@ describe('UserModel', () => {
|
||||
stripeConfig().enabled = false;
|
||||
});
|
||||
|
||||
test('should disable disable the account and send an email if payment failed for good', async () => {
|
||||
stripeConfig().enabled = true;
|
||||
|
||||
const { user: user1 } = await models().subscription().saveUserAndSubscription('toto@example.com', 'Toto', AccountType.Basic, 'usr_111', 'sub_111');
|
||||
|
||||
const sub = await models().subscription().byUserId(user1.id);
|
||||
|
||||
const now = Date.now();
|
||||
const paymentFailedTime = now - failedPaymentFinalAccount - 10;
|
||||
await models().subscription().save({
|
||||
id: sub.id,
|
||||
last_payment_time: now - failedPaymentFinalAccount * 2,
|
||||
last_payment_failed_time: paymentFailedTime,
|
||||
});
|
||||
|
||||
await models().user().handleFailedPaymentSubscriptions();
|
||||
|
||||
{
|
||||
const user1 = await models().user().loadByEmail('toto@example.com');
|
||||
expect(user1.enabled).toBe(0);
|
||||
|
||||
const email = (await models().email().all()).pop();
|
||||
expect(email.key).toBe(`payment_failed_account_disabled_${paymentFailedTime}`);
|
||||
expect(email.body).toContain(stripePortalUrl());
|
||||
}
|
||||
|
||||
stripeConfig().enabled = false;
|
||||
});
|
||||
|
||||
test('should send emails and flag accounts when it is over the size limit', async () => {
|
||||
const { user: user1 } = await createUserAndSession(1);
|
||||
const { user: user2 } = await createUserAndSession(2);
|
||||
|
Loading…
Reference in New Issue
Block a user