fix(shortSyntax): "asd #asd" case

This commit is contained in:
Johannes Millan 2020-10-15 15:51:52 +02:00
parent 5224491390
commit d8d5ae78ab
2 changed files with 20 additions and 1 deletions

View file

@ -185,6 +185,24 @@ describe('shortSyntax', () => {
});
});
it('should add new "asd #asd" tag', () => {
const t = {
...TASK,
title: 'asd #asd',
tagIds: []
};
const r = shortSyntax(t, ALL_TAGS);
expect(r).toEqual({
newTagTitles: ['asd'],
remindAt: null,
projectId: undefined,
taskChanges: {
title: 'asd',
}
});
});
it('should not add tags for sub tasks', () => {
const t = {
...TASK,

View file

@ -126,7 +126,8 @@ const parseTagChanges = (task: Partial<TaskCopy>, allTags?: Tag[]): { taskChange
.map(title => title.trim().replace(CH_TAG, ''))
.filter(newTagTitle =>
newTagTitle.length >= 1
&& initialTitle.trim().indexOf(newTagTitle) > 4
// NOTE: we check this to not trigger for "#123 blasfs dfasdf"
&& initialTitle.trim().lastIndexOf(newTagTitle) > 4
);
const tagIdsToAdd: string[] = [];