From 8e10bc7bc9b40ef7f7c38a3c63259621747edcd6 Mon Sep 17 00:00:00 2001 From: Evan Hahn Date: Wed, 4 Sep 2024 14:41:53 +0000 Subject: [PATCH] test: test validating a schema name that could "trick" JavaScript I was worried that bad schema names like `hasOwnProperty` or `constructor` could cause trouble. They don't (as far as I can tell) but I still think it's worth adding a fixture for it. --- test/fixtures/bad-docs.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/fixtures/bad-docs.js b/test/fixtures/bad-docs.js index 4e37aaf..a106ca8 100644 --- a/test/fixtures/bad-docs.js +++ b/test/fixtures/bad-docs.js @@ -24,6 +24,23 @@ export const badDocs = [ deleted: false, }, }, + { + text: 'test schema name that could "trick" JavaScript', + /** @type Omit & { schemaName: 'hasOwnProperty' }} */ + doc: { + docId: cachedValues.docId, + versionId: cachedValues.versionId, + originalVersionId: cachedValues.versionId, + schemaName: 'hasOwnProperty', + createdAt: cachedValues.createdAt, + updatedAt: cachedValues.updatedAt, + links: [], + attachments: [], + tags: {}, + metadata: {}, + deleted: false, + }, + }, { text: 'missing expected originalVersionId', /** @type Omit */