Skip to content

Commit

Permalink
test: test validating a schema name that could "trick" JavaScript
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
EvanHahn committed Sep 4, 2024
1 parent 7905f48 commit 51bca96
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/fixtures/bad-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ export const badDocs = [
deleted: false,
},
},
{
text: 'test schema name that could "trick" JavaScript',
/** @type Omit<import('../../dist/index.js').Observation, 'schemaName'> & { 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<import('../../dist/index.js').Observation, 'originalVersionId'> */
Expand Down

0 comments on commit 51bca96

Please sign in to comment.