Skip to content

Commit

Permalink
test: Add a test showing the behaviour of 'this week' in the modal
Browse files Browse the repository at this point in the history
See #2588.
  • Loading branch information
claremacrae committed Nov 27, 2024
1 parent 5edb992 commit 18478dd
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/ui/EditTask.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,15 @@ describe('Task editing', () => {
});

describe('Date editing', () => {
beforeEach(() => {
jest.useFakeTimers();
jest.setSystemTime(new Date('2024-11-27'));
});

afterEach(() => {
jest.useRealTimers();
});

const line = '- [ ] simple';

it('should edit and save cancelled date', async () => {
Expand All @@ -568,6 +577,21 @@ describe('Task editing', () => {
it('should edit and save start date', async () => {
expect(await editFieldAndSave(line, 'start', '2024-01-01')).toEqual('- [ ] simple 🛫 2024-01-01');
});

it('should edit and save start date "today"', async () => {
expect(await editFieldAndSave(line, 'start', 'today')).toEqual('- [ ] simple 🛫 2024-11-27');
});

it('should edit and save start date "this week"', async () => {
// Confirm understanding that today's date is a Wednesday
expect(moment().format('YYYY-MM-DD dddd')).toEqual('2024-11-27 Wednesday');

// See https://github.com/obsidian-tasks-group/obsidian-tasks/issues/2588
// With 'only future dates' being on by default, the selection of a date
// earlier than today is unexpected.
// This was written with Tasks using "chrono-node": "2.3.9"
expect(await editFieldAndSave(line, 'start', 'this week')).toEqual('- [ ] simple 🛫 2024-11-24');
});
});

describe('OnCompletion editing', () => {
Expand Down

0 comments on commit 18478dd

Please sign in to comment.