-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: test that all generated values can be encoded
After running this test I also noticed an issue with icons, where (inexplicably) the `blobVersionId` would sometimes be a regular string, not a version ID. I was able to fix this by changing the definition. I think this is a useful change on its own, but it will make future changes (such as upgrading some dependencies) much easier.
- Loading branch information
Showing
2 changed files
with
30 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { encode } from '@comapeo/schema' | ||
import test from 'node:test' | ||
import { generate, listSchemas } from '../index.js' | ||
|
||
test('generates encodable data', { concurrency: true }, async (t) => { | ||
const COUNT = 1000 | ||
|
||
const schemaNames = Object.keys(listSchemas()) | ||
|
||
for (const schemaName of schemaNames) { | ||
if (schemaName === 'coreOwnership') continue | ||
await t.test(schemaName, () => { | ||
for (const doc of generate(schemaName, { count: COUNT })) { | ||
// This should not throw. | ||
encode(doc) | ||
} | ||
}) | ||
} | ||
|
||
await t.test('coreOwnership', () => { | ||
for (const doc of generate('coreOwnership', { count: COUNT })) { | ||
// This should not throw. | ||
encode({ | ||
...doc, | ||
identitySignature: Buffer.alloc(32), | ||
}) | ||
} | ||
}) | ||
}) |