Skip to content

Commit a94e452

Browse files
authored
test: Simplify some tests in Task.test.ts (#853)
By using fromLine() in TestHelpers, instead of Task.fromLine() as the former is simpler to call, when we don't care about file and section names.
1 parent 650f652 commit a94e452

File tree

1 file changed

+9
-65
lines changed

1 file changed

+9
-65
lines changed

tests/Task.test.ts

Lines changed: 9 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,10 @@ describe('parsing', () => {
1313
it('parses a task from a line', () => {
1414
// Arrange
1515
const line = '- [x] this is a done task 🗓 2021-09-12 ✅ 2021-06-20';
16-
const path = 'this/is a path/to a/file.md';
17-
const sectionStart = 1337;
18-
const sectionIndex = 1209;
19-
const precedingHeader = 'Eloquent Section';
2016

2117
// Act
22-
const task = Task.fromLine({
18+
const task = fromLine({
2319
line,
24-
path,
25-
sectionStart,
26-
sectionIndex,
27-
precedingHeader,
2820
});
2921

3022
// Assert
@@ -46,18 +38,10 @@ describe('parsing', () => {
4638
const originalSettings = getSettings();
4739
updateSettings({ globalFilter: '#task' });
4840
const line = '- [x] this is a done task 🗓 2021-09-12 ✅ 2021-06-20';
49-
const path = 'this/is a path/to a/file.md';
50-
const sectionStart = 1337;
51-
const sectionIndex = 1209;
52-
const precedingHeader = 'Eloquent Section';
5341

5442
// Act
55-
const task = Task.fromLine({
43+
const task = fromLine({
5644
line,
57-
path,
58-
sectionStart,
59-
sectionIndex,
60-
precedingHeader,
6145
});
6246

6347
// Assert
@@ -70,18 +54,10 @@ describe('parsing', () => {
7054
it('allows signifier emojis as part of the description', () => {
7155
// Arrange
7256
const line = '- [x] this is a ✅ done task 🗓 2021-09-12 ✅ 2021-06-20';
73-
const path = 'this/is a path/to a/file.md';
74-
const sectionStart = 1337;
75-
const sectionIndex = 1209;
76-
const precedingHeader = 'Eloquent Section';
7757

7858
// Act
79-
const task = Task.fromLine({
59+
const task = fromLine({
8060
line,
81-
path,
82-
sectionStart,
83-
sectionIndex,
84-
precedingHeader,
8561
});
8662

8763
// Assert
@@ -102,18 +78,10 @@ describe('parsing', () => {
10278
// Arrange
10379
const line =
10480
'- [x] this is a ✅ done task 🗓 2021-09-12 ✅ 2021-06-20 ^my-precious ';
105-
const path = 'this/is a path/to a/file.md';
106-
const sectionStart = 1337;
107-
const sectionIndex = 1209;
108-
const precedingHeader = 'Eloquent Section';
10981

11082
// Act
111-
const task = Task.fromLine({
83+
const task = fromLine({
11284
line,
113-
path,
114-
sectionStart,
115-
sectionIndex,
116-
precedingHeader,
11785
});
11886

11987
// Assert
@@ -314,12 +282,8 @@ describe('to string', () => {
314282
const line = '- [ ] this is a task 📅 2021-09-12 ^my-precious';
315283

316284
// Act
317-
const task: Task = Task.fromLine({
285+
const task: Task = fromLine({
318286
line,
319-
path: '',
320-
sectionStart: 0,
321-
sectionIndex: 0,
322-
precedingHeader: '',
323287
}) as Task;
324288

325289
// Assert
@@ -333,12 +297,8 @@ describe('to string', () => {
333297
'- [x] this is a done task #tagone 📅 2021-09-12 ✅ 2021-06-20 #journal/daily';
334298

335299
// Act
336-
const task: Task = Task.fromLine({
300+
const task: Task = fromLine({
337301
line,
338-
path: '',
339-
sectionStart: 0,
340-
sectionIndex: 0,
341-
precedingHeader: '',
342302
}) as Task;
343303

344304
// Assert
@@ -354,12 +314,8 @@ describe('toggle done', () => {
354314
const line = '- [ ] this is a task 📅 2021-09-12 ^my-precious';
355315

356316
// Act
357-
const task: Task = Task.fromLine({
317+
const task: Task = fromLine({
358318
line,
359-
path: '',
360-
sectionStart: 0,
361-
sectionIndex: 0,
362-
precedingHeader: '',
363319
}) as Task;
364320
const toggled: Task = task.toggle()[0];
365321

@@ -614,12 +570,8 @@ describe('toggle done', () => {
614570
.filter(Boolean)
615571
.join(' ');
616572

617-
const task = Task.fromLine({
573+
const task = fromLine({
618574
line,
619-
path: '',
620-
precedingHeader: '',
621-
sectionStart: 0,
622-
sectionIndex: 0,
623575
});
624576

625577
const nextTask: Task = task!.toggle()[0];
@@ -643,18 +595,10 @@ describe('toggle done', () => {
643595
it('supports recurrence rule after a due date', () => {
644596
// Arrange
645597
const line = '- [ ] this is a task 🗓 2021-09-12 🔁 every day';
646-
const path = 'this/is a path/to a/file.md';
647-
const sectionStart = 1337;
648-
const sectionIndex = 1209;
649-
const precedingHeader = 'Eloquent Section';
650598

651599
// Act
652-
const task = Task.fromLine({
600+
const task = fromLine({
653601
line,
654-
path,
655-
sectionStart,
656-
sectionIndex,
657-
precedingHeader,
658602
});
659603

660604
// Assert

0 commit comments

Comments
 (0)