Skip to content

Commit

Permalink
Refactoring wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ransome1 committed Apr 5, 2024
1 parent fd08ecd commit 882d4da
Show file tree
Hide file tree
Showing 34 changed files with 421 additions and 397 deletions.
28 changes: 14 additions & 14 deletions src/__tests__/__mock__/recurrence.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

2024-04-04 Line 1 rec:1d due:2024-04-05
2024-04-04 Line 1 rec:w due:2024-04-11
2024-04-04 Line 1 rec:2m due:2024-06-04
2024-04-04 Line 1 rec:+1d due:2024-04-06
2024-04-04 Line 1 rec:7w due:2024-05-23
2024-04-04 Line 1 due:2023-07-24 rec:+1b
2024-04-04 taxes are due in one year t:2022-03-30 due:2022-04-30 rec:+1y
2024-04-04 Water plants @home +quick due:2024-04-11 t:2024-04-01 rec:1w
2024-04-04 Line 1 rec:+1d t:2023-09-20
2024-04-04 Line 1 rec:1d pri:A due:2024-04-05
2024-04-04 (A) Do something rec:d t:2024-04-05 @SomeContext
2024-04-04 Do something rec:0d
2024-04-04 Do something rec:0d due:2024-04-04
2024-04-04 Do something rec:0d due:2024-04-04 t:2024-04-04
2024-04-05 Line 1 rec:1d due:2024-04-06
2024-04-05 Line 1 rec:w due:2024-04-12
2024-04-05 Line 1 rec:2m due:2024-06-05
2024-04-05 Line 1 rec:+1d due:2024-04-07
2024-04-05 Line 1 rec:7w due:2024-05-24
2024-04-05 Line 1 due:2023-07-24 rec:+1b
2024-04-05 taxes are due in one year t:2022-03-30 due:2022-04-30 rec:+1y
2024-04-05 Water plants @home +quick due:2024-04-12 t:2024-04-02 rec:1w
2024-04-05 Line 1 rec:+1d t:2023-09-20
2024-04-05 Line 1 rec:1d pri:A due:2024-04-06
2024-04-05 (A) Do something rec:d t:2024-04-06 @SomeContext
2024-04-05 Do something rec:0d
2024-04-05 Do something rec:0d due:2024-04-05
2024-04-05 Do something rec:0d due:2024-04-05 t:2024-04-05
12 changes: 6 additions & 6 deletions src/__tests__/main/Attributes.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { attributes, updateAttributes } from '../../main/modules/Attributes';

const todoObjects = [
{ id: 1, created: null, priority: 'A', projects: ['Project 1'], contexts: ['Context 1'], due: '2023-01-01', dueString: '2023-01-01', complete: false, completed: null, t: '2024-02-01', tString: '2024-02-01', rec: null, pm: null, body: null, hidden: false, string: '', notify: false, visible: true, },
{ id: 2, created: '2026-01-01', priority: null, projects: ['Project 2'], contexts: null, due: '2023-02-01', dueString: '2023-02-01', complete: false, completed: null, t: null, tString: null, rec: null, pm: null, body: null, hidden: false, string: '', notify: false, visible: true, },
{ id: 3, created: null, priority: null, projects: ['Project 1'], contexts: null, due: '2023-03-01', dueString: '2023-03-01', complete: false, completed: null, t: null, tString: null, rec: '2b', pm: null, body: null, hidden: false, string: '', notify: true, visible: true, },
{ id: 4, created: '2026-01-01', priority: 'C', projects: ['Project 2'], contexts: ['Context 1'], due: '2023-04-01', dueString: '2023-04-01', complete: false, completed: null, t: '2024-02-01', tString: '2024-02-01', rec: null, pm: null, body: null, hidden: false, string: '', notify: false, visible: true, },
{ lineNumber: 1, created: null, priority: 'A', projects: ['Project 1'], contexts: ['Context 1'], due: '2023-01-01', dueString: '2023-01-01', complete: false, completed: null, t: '2024-02-01', tString: '2024-02-01', rec: null, pm: null, body: null, hidden: false, string: '', notify: false, },
{ lineNumber: 2, created: '2026-01-01', priority: null, projects: ['Project 2'], contexts: null, due: '2023-02-01', dueString: '2023-02-01', complete: false, completed: null, t: null, tString: null, rec: null, pm: null, body: null, hidden: false, string: '', notify: false, },
{ lineNumber: 3, created: null, priority: null, projects: ['Project 1'], contexts: null, due: '2023-03-01', dueString: '2023-03-01', complete: false, completed: null, t: null, tString: null, rec: '2b', pm: null, body: null, hidden: false, string: '', notify: true, },
{ lineNumber: 4, created: '2026-01-01', priority: 'C', projects: ['Project 2'], contexts: ['Context 1'], due: '2023-04-01', dueString: '2023-04-01', complete: false, completed: null, t: '2024-02-01', tString: '2024-02-01', rec: null, pm: null, body: null, hidden: false, string: '', notify: false, },
];

describe('Set of filters must create a respective set of attributes and its counts', () => {
test('Should create attributes based on todo objects', async () => {
test('Should create attributes based on todo objects', () => {

const sorting = [
{ id: '1', value: 'priority', invert: false },
Expand All @@ -33,7 +33,7 @@ describe('Set of filters must create a respective set of attributes and its coun
created: { '2026-01-01': { count: 2, notify: false} },
completed: {},
};
await updateAttributes(todoObjects, sorting, false);
updateAttributes(todoObjects, sorting, false);
expect(attributes).toEqual(expectedAttributes);
});

Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/main/ChangeCompleteState.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { changeCompleteState } from '../../main/modules/ProcessDataRequest/ChangeCompleteState';
import { changeCompleteState } from '../../main/modules/DataRequest/ChangeCompleteState';
import dayjs from 'dayjs';

const date: string = dayjs(new Date()).format('YYYY-MM-DD');

jest.mock('../../main/modules/ProcessDataRequest/CreateRecurringTodo', () => ({
jest.mock('../../main/modules/DataRequest/CreateRecurringTodo', () => ({
createRecurringTodo: jest.fn(),
}));

Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/main/CreateRecurringTodo.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from 'fs';
import { createRecurringTodo } from '../../main/modules/ProcessDataRequest/CreateRecurringTodo';
import { createRecurringTodo } from '../../main/modules/DataRequest/CreateRecurringTodo';
import dayjs from 'dayjs';

jest.mock('../../main/modules/ProcessDataRequest/CreateTodoObjects', () => ({
jest.mock('../../main/modules/DataRequest/CreateTodoObjects', () => ({
linesInFile: [''],
}));

Expand Down
26 changes: 11 additions & 15 deletions src/__tests__/main/CreateTodoObjects.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createTodoObjects } from '../../main/modules/ProcessDataRequest/CreateTodoObjects';
import { createTodoObjects } from '../../main/modules/DataRequest/CreateTodoObjects';

jest.mock('electron', () => ({
app: {
Expand Down Expand Up @@ -28,7 +28,7 @@ describe('Create todo objects', () => {
test('should create a todo object', async () => {
const todoObjects = await createTodoObjects(fileContent);
expect(todoObjects[0]).toEqual({
id: 0,
lineNumber: 0,
body: 'Test +project @context todo 1 due:2023-12-31 t:2024-03-24 h:1 test @anotherContext pm:4 and a strict rec:+2w',
created: null,
complete: false,
Expand All @@ -45,21 +45,20 @@ describe('Create todo objects', () => {
pm: "4",
string: '(B) Test +project @context todo 1 due:2023-12-31 t:2024-03-24 h:1 test @anotherContext pm:4 and a strict rec:+2w',
notify: false,
visible: true,
});
});

test('should create a finished todo object', async () => {
const todoObjects = await createTodoObjects(fileContent);
expect(todoObjects[1]).toEqual({
id: 1,
lineNumber: 1,
body: 'Test todo 2',
created: '2023-07-21',
complete: true,
completed: '2023-07-23',
priority: null,
contexts: [],
projects: [],
contexts: null,
projects: null,
due: null,
dueString: null,
t: null,
Expand All @@ -69,21 +68,20 @@ describe('Create todo objects', () => {
pm: null,
string: 'x 2023-07-23 2023-07-21 Test todo 2',
notify: false,
visible: true,
});
});

test('should create a todo object with speaking due date', async () => {
const todoObjects = await createTodoObjects(fileContent);
expect(todoObjects[2]).toEqual({
id: 2,
lineNumber: 2,
body: 'Test todo 3 due:end of the year',
created: null,
complete: false,
completed: null,
priority: null,
contexts: [],
projects: [],
contexts: null,
projects: null,
due: '2024-12-31',
dueString: 'end of the year',
t: null,
Expand All @@ -93,21 +91,20 @@ describe('Create todo objects', () => {
pm: null,
string: 'Test todo 3 due:end of the year',
notify: false,
visible: true,
});
});

test('should create a todo object with speaking t date', async () => {
const todoObjects = await createTodoObjects(fileContent);
expect(todoObjects[3]).toEqual({
id: 3,
lineNumber: 3,
body: 'Test todo 4 t:first day of next year',
created: null,
complete: false,
completed: null,
priority: null,
contexts: [],
projects: [],
contexts: null,
projects: null,
due: null,
dueString: null,
t: '2025-01-01',
Expand All @@ -117,7 +114,6 @@ describe('Create todo objects', () => {
pm: null,
string: 'Test todo 4 t:first day of next year',
notify: false,
visible: true,
});
});
});
Loading

0 comments on commit 882d4da

Please sign in to comment.