-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add ava config and some basic tests (#215)
This needs some cleanup, but I got ava + typescript to work after a bit of wrestling. So far I've only added some simple tests to keyring-core that don't depend on the service, but I've also started on a mock access service so we can test `registerSpace`, etc. I had to add `"type": "module"` to the keyring-core package.json to get the ava + typescript setup to work. That seems pretty safe, since we're only including the rollup bundle in the published package, so it shouldn't make a difference to users. It seems like the mock services would be useful for all the packages, so maybe we should make a shared `test-utils` package? Co-authored-by: Travis Vachon <[email protected]>
- Loading branch information
1 parent
96d6c9b
commit 4bd233b
Showing
9 changed files
with
727 additions
and
1,424 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,15 @@ | ||
export default { | ||
files: [ | ||
'test/**', | ||
'!test/utils/' | ||
], | ||
extensions: { | ||
ts: 'module' | ||
}, | ||
nodeArguments: [ | ||
'--loader=ts-node/esm', | ||
// the following options lets us avoid file extensions in imports | ||
// per https://github.com/avajs/ava/blob/main/docs/recipes/typescript.md#for-packages-with-type-module | ||
'--experimental-specifier-resolution=node' | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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 test from 'ava' | ||
import { JSDOM } from 'jsdom' | ||
import 'fake-indexeddb/auto' | ||
|
||
import { createAgent } from '../src/index' | ||
|
||
test.before((t) => { | ||
const dom = new JSDOM('<!DOCTYPE html>') | ||
globalThis.document = dom.window.document | ||
}) | ||
|
||
test('createAgent', async (t) => { | ||
const agent = await createAgent() | ||
t.truthy(agent) | ||
t.true(agent.did().startsWith('did:key')) | ||
t.is(agent.spaces.size, 0) | ||
}) | ||
|
||
test('createSpace', async (t) => { | ||
const agent = await createAgent() | ||
const space = await agent.createSpace('test') | ||
t.truthy(space) | ||
t.true(space.did.startsWith('did:key:')) | ||
}) | ||
|
||
test('registerSpace fails if no current space is set', async (t) => { | ||
const agent = await createAgent() | ||
await t.throwsAsync(agent.registerSpace('[email protected]')) | ||
}) |
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
Oops, something went wrong.