From 1876820c4ec5f2dd17006e8efd5cba2eb1e60b3e Mon Sep 17 00:00:00 2001 From: Vladimir Razuvaev Date: Tue, 14 Apr 2020 18:43:34 +0700 Subject: [PATCH] chore(gatsby): Test sift filtering on date instances (skipped for now) --- .../gatsby/src/schema/__tests__/node-model.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/gatsby/src/schema/__tests__/node-model.js b/packages/gatsby/src/schema/__tests__/node-model.js index cb736bab5680f..f60b04f67f23f 100644 --- a/packages/gatsby/src/schema/__tests__/node-model.js +++ b/packages/gatsby/src/schema/__tests__/node-model.js @@ -457,6 +457,33 @@ describe(`NodeModel`, () => { expect(result).toBeDefined() expect(result.id).toEqual(`post2`) }) + + // FIXME: Filters on date instances are not supported yet + // SIFT requires such filters to be expressed as Date instances but we + // don't know if date is stored as `Date` instance or `string` + // so can't really do that + // See https://github.com/crcn/sift.js#date-comparison + it.skip(`queries date instances in nodes`, async () => { + const type = `Post` + const query = { + filter: { + frontmatter: { + date: { lte: `2018-01-01T00:00:00Z` }, + }, + }, + } + const firstOnly = false + nodeModel.replaceTypeKeyValueCache(createFiltersCache()) + const result = await nodeModel.runQuery({ + query, + firstOnly, + type, + }) + expect(result).toBeDefined() + expect(result.length).toEqual(2) + expect(result[0].id).toEqual(`post2`) + expect(result[1].id).toEqual(`post3`) + }) }) })