Skip to content

Commit 6e9ef4e

Browse files
authored
test: move a parsing test to correct section (#857)
* test: Move a parsing test in to the correct group. This is a tiny follow-up to finish off #850. * test: Stop WebStorm complaining about needless variable * test: Stop WebStorm complaining about http in test strings
1 parent a94e452 commit 6e9ef4e

File tree

1 file changed

+39
-40
lines changed

1 file changed

+39
-40
lines changed

tests/Task.test.ts

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,40 @@ describe('parsing', () => {
122122
expect(task!.dueDate!.isSame(moment('2021-09-12', 'YYYY-MM-DD')));
123123
expect(task!.priority == Priority.High);
124124
});
125+
126+
it('supports parsing large number of values', () => {
127+
// Arrange
128+
const line =
129+
'- [ ] Wobble ⏫ #tag1 ✅ 2022-07-02 #tag2 📅 2022-07-02 #tag3 ⏳ 2022-07-02 #tag4 🛫 2022-07-02 #tag5 🔁 every day #tag6 #tag7 #tag8 #tag9 #tag10';
130+
131+
// Act
132+
const task = fromLine({
133+
line,
134+
});
135+
136+
// Assert
137+
expect(task).not.toBeNull();
138+
expect(task!.description).toEqual(
139+
'Wobble #tag1 #tag2 #tag3 #tag4 #tag5 #tag6 #tag7 #tag8 #tag9 #tag10',
140+
);
141+
expect(task!.dueDate!.isSame(moment('022-07-02', 'YYYY-MM-DD')));
142+
expect(task!.doneDate!.isSame(moment('022-07-02', 'YYYY-MM-DD')));
143+
expect(task!.startDate!.isSame(moment('022-07-02', 'YYYY-MM-DD')));
144+
expect(task!.scheduledDate!.isSame(moment('022-07-02', 'YYYY-MM-DD')));
145+
expect(task!.priority == Priority.High);
146+
expect(task!.tags).toStrictEqual([
147+
'#tag1',
148+
'#tag2',
149+
'#tag3',
150+
'#tag4',
151+
'#tag5',
152+
'#tag6',
153+
'#tag7',
154+
'#tag8',
155+
'#tag9',
156+
'#tag10',
157+
]);
158+
});
125159
});
126160

127161
type TagParsingExpectations = {
@@ -132,14 +166,13 @@ type TagParsingExpectations = {
132166
};
133167

134168
function constructTaskFromLine(line: string) {
135-
const task = Task.fromLine({
169+
return Task.fromLine({
136170
line,
137171
path: 'file.md',
138172
sectionStart: 0,
139173
sectionIndex: 0,
140174
precedingHeader: '',
141175
});
142-
return task;
143176
}
144177

145178
describe('parsing tags', () => {
@@ -224,17 +257,17 @@ describe('parsing tags', () => {
224257
},
225258
{
226259
markdownTask:
227-
'- [ ] Export [Cloud Feedly feeds](http://cloud.feedly.com/#opml) #context/pc_clare 🔁 every 4 weeks on Sunday ⏳ 2022-05-15 #context/more_context',
260+
'- [ ] Export [Cloud Feedly feeds](https://cloud.feedly.com/#opml) #context/pc_clare 🔁 every 4 weeks on Sunday ⏳ 2022-05-15 #context/more_context',
228261
expectedDescription:
229-
'Export [Cloud Feedly feeds](http://cloud.feedly.com/#opml) #context/pc_clare #context/more_context',
262+
'Export [Cloud Feedly feeds](https://cloud.feedly.com/#opml) #context/pc_clare #context/more_context',
230263
extractedTags: ['#context/pc_clare', '#context/more_context'],
231264
globalFilter: '',
232265
},
233266
{
234267
markdownTask:
235-
'- [ ] Export [Cloud Feedly feeds](http://cloud.feedly.com/#opml) #context/pc_clare ⏳ 2022-05-15 🔁 every 4 weeks on Sunday #context/more_context',
268+
'- [ ] Export [Cloud Feedly feeds](https://cloud.feedly.com/#opml) #context/pc_clare ⏳ 2022-05-15 🔁 every 4 weeks on Sunday #context/more_context',
236269
expectedDescription:
237-
'Export [Cloud Feedly feeds](http://cloud.feedly.com/#opml) #context/pc_clare #context/more_context',
270+
'Export [Cloud Feedly feeds](https://cloud.feedly.com/#opml) #context/pc_clare #context/more_context',
238271
extractedTags: ['#context/pc_clare', '#context/more_context'],
239272
globalFilter: '',
240273
},
@@ -619,38 +652,4 @@ describe('toggle done', () => {
619652
nextStart: undefined,
620653
});
621654
});
622-
623-
it('supports parsing large number of values', () => {
624-
// Arrange
625-
const line =
626-
'- [ ] Wobble ⏫ #tag1 ✅ 2022-07-02 #tag2 📅 2022-07-02 #tag3 ⏳ 2022-07-02 #tag4 🛫 2022-07-02 #tag5 🔁 every day #tag6 #tag7 #tag8 #tag9 #tag10';
627-
628-
// Act
629-
const task = fromLine({
630-
line,
631-
});
632-
633-
// Assert
634-
expect(task).not.toBeNull();
635-
expect(task!.description).toEqual(
636-
'Wobble #tag1 #tag2 #tag3 #tag4 #tag5 #tag6 #tag7 #tag8 #tag9 #tag10',
637-
);
638-
expect(task!.dueDate!.isSame(moment('022-07-02', 'YYYY-MM-DD')));
639-
expect(task!.doneDate!.isSame(moment('022-07-02', 'YYYY-MM-DD')));
640-
expect(task!.startDate!.isSame(moment('022-07-02', 'YYYY-MM-DD')));
641-
expect(task!.scheduledDate!.isSame(moment('022-07-02', 'YYYY-MM-DD')));
642-
expect(task!.priority == Priority.High);
643-
expect(task!.tags).toStrictEqual([
644-
'#tag1',
645-
'#tag2',
646-
'#tag3',
647-
'#tag4',
648-
'#tag5',
649-
'#tag6',
650-
'#tag7',
651-
'#tag8',
652-
'#tag9',
653-
'#tag10',
654-
]);
655-
});
656655
});

0 commit comments

Comments
 (0)