From 518417c0de61573d1373cd3eb2ebd1c2d72fbe2b Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 31 Jul 2022 18:16:19 +0200 Subject: [PATCH] feat: add more testcases for parsing weekdays Related to https://kolaente.dev/vikunja/api/issues/1223 --- src/modules/parseTaskText.test.ts | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/modules/parseTaskText.test.ts b/src/modules/parseTaskText.test.ts index 40847063..90208b88 100644 --- a/src/modules/parseTaskText.test.ts +++ b/src/modules/parseTaskText.test.ts @@ -314,6 +314,42 @@ describe('Parse Task Text', () => { expect(result.text).toBe('Lorem Ipsum github') expect(result.date).toBeNull() }) + describe('Should not recognize weekdays in words', () => { + const cases = [ + 'renewed', + 'github', + 'fix monitor stand', + 'order wedding cake', + 'investigate thumping noise', + 'iron frilly napkins', + 'take photo of saturn', + 'fix sunglasses', + 'monitor blood pressure', + 'Monitor blood pressure', + 'buy almonds', + ] + + cases.forEach(c => { + it(`should not recognize text with ${c} at the beginning as weekday`, () => { + const result = parseTaskText(`${c} dolor sit amet`) + + expect(result.text).toBe(`${c} dolor sit amet`) + expect(result.date).toBeNull() + }) + it(`should not recognize text with ${c} at the end as weekday`, () => { + const result = parseTaskText(`Lorem Ipsum ${c}`) + + expect(result.text).toBe(`Lorem Ipsum ${c}`) + expect(result.date).toBeNull() + }) + it(`should not recognize text with ${c} as weekday`, () => { + const result = parseTaskText(`Lorem Ipsum ${c} dolor`) + + expect(result.text).toBe(`Lorem Ipsum ${c} dolor`) + expect(result.date).toBeNull() + }) + }) + }) it('should not recognize date number with no spacing around them', () => { const result = parseTaskText('Lorem Ispum v1.1.1')