Skip to content

Commit

Permalink
more adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
vdusart committed Nov 24, 2023
1 parent 19c9d52 commit 6697e6d
Showing 1 changed file with 9 additions and 126 deletions.
135 changes: 9 additions & 126 deletions tests/Query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,21 +685,6 @@ describe('Query', () => {
],
},
],
[
'by due date presence uppercase',
{
filters: ['HAS DUE DATE'],
tasks: [
'- [ ] task 1',
'- [ ] task 2 🛫 2022-04-20 ⏳ 2022-04-20 📅 2022-04-20',
'- [ ] task 3 📅 2022-04-20',
],
expectedResult: [
'- [ ] task 2 🛫 2022-04-20 ⏳ 2022-04-20 📅 2022-04-20',
'- [ ] task 3 📅 2022-04-20',
],
},
],
[
'by start date presence',
{
Expand All @@ -715,21 +700,6 @@ describe('Query', () => {
],
},
],
[
'by start date presence uppercase',
{
filters: ['HAS START DATE'],
tasks: [
'- [ ] task 1',
'- [ ] task 2 🛫 2022-04-20 ⏳ 2022-04-20 📅 2022-04-20',
'- [ ] task 3 🛫 2022-04-20',
],
expectedResult: [
'- [ ] task 2 🛫 2022-04-20 ⏳ 2022-04-20 📅 2022-04-20',
'- [ ] task 3 🛫 2022-04-20',
],
},
],
[
'by scheduled date presence',
{
Expand All @@ -745,21 +715,6 @@ describe('Query', () => {
],
},
],
[
'by scheduled date presence uppercase',
{
filters: ['HAS SCHEDULED DATE'],
tasks: [
'- [ ] task 1',
'- [ ] task 2 🛫 2022-04-20 ⏳ 2022-04-20 📅 2022-04-20',
'- [ ] task 3 ⏳ 2022-04-20',
],
expectedResult: [
'- [ ] task 2 🛫 2022-04-20 ⏳ 2022-04-20 📅 2022-04-20',
'- [ ] task 3 ⏳ 2022-04-20',
],
},
],
[
'by due date absence',
{
Expand All @@ -772,18 +727,6 @@ describe('Query', () => {
expectedResult: ['- [ ] task 1'],
},
],
[
'by due date absence uppercase',
{
filters: ['NO DUE DATE'],
tasks: [
'- [ ] task 1',
'- [ ] task 2 🛫 2022-04-20 ⏳ 2022-04-20 📅 2022-04-20',
'- [ ] task 3 📅 2022-04-20',
],
expectedResult: ['- [ ] task 1'],
},
],
[
'by start date absence',
{
Expand All @@ -796,18 +739,6 @@ describe('Query', () => {
expectedResult: ['- [ ] task 1'],
},
],
[
'by start date absence uppercase',
{
filters: ['NO START DATE'],
tasks: [
'- [ ] task 1',
'- [ ] task 2 🛫 2022-04-20 ⏳ 2022-04-20 📅 2022-04-20',
'- [ ] task 3 🛫 2022-04-20',
],
expectedResult: ['- [ ] task 1'],
},
],
[
'by scheduled date absence',
{
Expand All @@ -820,18 +751,6 @@ describe('Query', () => {
expectedResult: ['- [ ] task 1'],
},
],
[
'by scheduled date absence uppercase',
{
filters: ['NO SCHEDULED DATE'],
tasks: [
'- [ ] task 1',
'- [ ] task 2 🛫 2022-04-20 ⏳ 2022-04-20 📅 2022-04-20',
'- [ ] task 3 ⏳ 2022-04-20',
],
expectedResult: ['- [ ] task 1'],
},
],
[
'by start date (before)',
{
Expand All @@ -848,22 +767,6 @@ describe('Query', () => {
],
},
],
[
'by start date (before) uppercase',
{
filters: ['STARTS BEFORE 2022-04-20'],
tasks: [
'- [ ] task 1',
'- [ ] task 2 🛫 2022-04-15',
'- [ ] task 3 🛫 2022-04-20',
'- [ ] task 4 🛫 2022-04-25',
],
expectedResult: [
'- [ ] task 1', // reference: https://publish.obsidian.md/tasks/Queries/Filters#Start+Date
'- [ ] task 2 🛫 2022-04-15',
],
},
],
[
'by scheduled date (before)',
{
Expand All @@ -877,19 +780,6 @@ describe('Query', () => {
expectedResult: ['- [ ] task 2 ⏳ 2022-04-15'],
},
],
[
'by scheduled date (before) uppercase',
{
filters: ['SCHEDULED BEFORE 2022-04-20'],
tasks: [
'- [ ] task 1',
'- [ ] task 2 ⏳ 2022-04-15',
'- [ ] task 3 ⏳ 2022-04-20',
'- [ ] task 4 ⏳ 2022-04-25',
],
expectedResult: ['- [ ] task 2 ⏳ 2022-04-15'],
},
],
[
'by done date (before)',
{
Expand All @@ -901,26 +791,16 @@ describe('Query', () => {
expectedResult: ['- [ ] I am done before filter, and should pass ✅ 2022-12-01'],
},
],
[
'by done date (before) uppercase',
{
filters: ['DONE BEFORE 2022-12-23'],
tasks: [
'- [ ] I am done before filter, and should pass ✅ 2022-12-01',
'- [ ] I have no done date, so should fail',
],
expectedResult: ['- [ ] I am done before filter, and should pass ✅ 2022-12-01'],
},
],
])('should support filtering %s', (_, { tasks: allTaskLines, filters, expectedResult }) => {
shouldSupportFiltering(filters, allTaskLines, expectedResult);
shouldSupportFiltering(
filters.map((filter) => filter.toUpperCase()),
allTaskLines,
expectedResult,
);
});
});

// ---------------------------------
// ---------------------------------
// ---------------------------------

describe('filtering with "happens"', () => {
type HappensCase = {
description: string;
Expand Down Expand Up @@ -948,7 +828,7 @@ describe('Query', () => {
},
{
description: 'on: should match if scheduled matches',
happensFilter: 'HAPPENS on 2012-03-04',
happensFilter: 'happens on 2012-03-04',
scheduled: '2012-03-04',
taskShouldMatch: true,
},
Expand Down Expand Up @@ -1049,6 +929,7 @@ describe('Query', () => {

// Act, Assert
shouldSupportFiltering([happensFilter], [line], expectedResult);
shouldSupportFiltering([happensFilter.toUpperCase()], [line], expectedResult);
},
);
});
Expand Down Expand Up @@ -1624,13 +1505,15 @@ At most 8 tasks per group (if any "group by" options are supplied).
(description includes line 1 continued\
with \ backslash)`;
const query = new Query(source);
const queryUpperCase = new Query(source);

const expectedDisplayText = String.raw`(description includes line 1) OR (description includes line 1 continued with \ backslash) =>
OR (At least one of):
description includes line 1
description includes line 1 continued with \ backslash
`;
expect(query.explainQuery()).toEqual(expectedDisplayText);
expect(queryUpperCase.explainQuery()).toEqual(expectedDisplayText);
});
});
});

0 comments on commit 6697e6d

Please sign in to comment.