-
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.
Merge branch 'master' of https://github.com/sambacha/abi-schema-registry
- Loading branch information
Showing
4 changed files
with
50 additions
and
112 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# CI for command line NodeJS Applications | ||
name: nodejs | ||
on: | ||
push: | ||
paths: | ||
- "**/**" | ||
- "!**/*.md/**" | ||
|
||
env: | ||
CI: true | ||
FORCE_COLOR: 2 | ||
|
||
jobs: | ||
run: | ||
name: Node ${{ matrix.node }} on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node: ['14'] | ||
os: ['ubuntu-latest'] | ||
|
||
steps: | ||
- name: Clone repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
|
||
- name: Install npm dependencies | ||
run: cd tray/ && npm install | ||
|
||
- name: Run build | ||
run: npm run build |
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 |
---|---|---|
@@ -1,97 +1,16 @@ | ||
import { validateSchemaDid, parseSchemaDid, stringifySchemaDid } from '../did/did-utils'; | ||
import { SchemaDid, Network, SchemaType } from '../model'; | ||
|
||
test('DID start without "did" returns false', () => { | ||
const invalidDid = `d:schema:node-ipfs:json-schema:0xa937ea507c396d8d417be352825c65f5fdf1e6fb60e8368db03f2cccda05567c`; | ||
const validationResult = validateSchemaDid(invalidDid); | ||
expect(validationResult).toBe(false); | ||
}); | ||
|
||
test('DID has no "schema" returns false', () => { | ||
const invalidDid = `did:node-ipfs:json-schema:0xa937ea507c396d8d417be352825c65f5fdf1e6fb60e8368db03f2cccda05567c`; | ||
const validationResult = validateSchemaDid(invalidDid); | ||
expect(validationResult).toBe(false); | ||
}); | ||
|
||
test('DID has a not supported network returns false', () => { | ||
const invalidDid = `did:schema:node_test_ipfs:json-schema:0xa937ea507c396d8d417be352825c65f5fdf1e6fb60e8368db03f2cccda05567c`; | ||
const validationResult = validateSchemaDid(invalidDid); | ||
expect(validationResult).toBe(false); | ||
}); | ||
|
||
test('DID has a not supported "type-hint" returns false', () => { | ||
const invalidDid = `did:node-ipfs:q-schema:0xa937ea507c396d8d417be352825c65f5fdf1e6fb60e8368db03f2cccda05567c`; | ||
const validationResult = validateSchemaDid(invalidDid); | ||
expect(validationResult).toBe(false); | ||
}); | ||
|
||
test('DID has no "hash" returns false', () => { | ||
const invalidDid = `did:schema:node-ipfs:json-schema:`; | ||
const validationResult = validateSchemaDid(invalidDid); | ||
expect(validationResult).toBe(false); | ||
}); | ||
|
||
test('DID has no "hash" and no "type hint" returns false', () => { | ||
const invalidDid = `did:schema:node-ipfs:`; | ||
const validationResult = validateSchemaDid(invalidDid); | ||
expect(validationResult).toBe(false); | ||
}); | ||
|
||
test('correct DID with ipfs hash returns true', () => { | ||
const validDid = `did:schema:node-ipfs:json-schema:QmNLei78zWmzUdbeRB3CiUfAizWUrbeeZh5K1rhAQKCh51`; | ||
const validationResult = validateSchemaDid(validDid); | ||
expect(validationResult).toBe(true); | ||
}); | ||
|
||
test('correct DID with node ipfs as network returns true', () => { | ||
const validDid = `did:schema:node-ipfs:json-schema:0xa937ea507c396d8d417be352825c65f5fdf1e6fb60e8368db03f2cccda05567c`; | ||
const validationResult = validateSchemaDid(validDid); | ||
expect(validationResult).toBe(true); | ||
}); | ||
|
||
test('correct DID with id includes - . _ returns true', () => { | ||
const validDid = `did:schema:node-ipfs:json-schema:0xa937ea507c396d_d417be352825c65-5fdf1e6fb60e83.8db03f2cccda05567c`; | ||
const validationResult = validateSchemaDid(validDid); | ||
expect(validationResult).toBe(true); | ||
}); | ||
|
||
test('correct DID with public ipfs as network returns true', () => { | ||
const validDid = `did:schema:public-ipfs:json-schema:0xa937ea507c396d8d417be352825c65f5fdf1e6fb60e8368db03f2cccda05567c`; | ||
const validationResult = validateSchemaDid(validDid); | ||
expect(validationResult).toBe(true); | ||
}); | ||
|
||
test('DID has no "type-hint" returns true', () => { | ||
const validDid = `did:schema:node-ipfs:0xa937ea507c396d8d417be352825c65f5fdf1e6fb60e8368db03f2cccda05567c`; | ||
const validationResult = validateSchemaDid(validDid); | ||
expect(validationResult).toBe(true); | ||
}); | ||
|
||
test('parse and stringify did with type hint', () => { | ||
const didObject: SchemaDid = { | ||
did: 'did', | ||
method: 'schema', | ||
network: Network.NodeIpfs, | ||
typeHint: SchemaType.JsonSchema, | ||
hash: '0xa937ea507c396d8d417be352825c65f5fdf1e6fb60e8368db03f2cccda05567c' | ||
} | ||
const validDid = `did:schema:node-ipfs:json-schema:0xa937ea507c396d8d417be352825c65f5fdf1e6fb60e8368db03f2cccda05567c`; | ||
const resultObject = parseSchemaDid(validDid); | ||
expect(resultObject).toStrictEqual(didObject); | ||
const didAsString = stringifySchemaDid(resultObject); | ||
expect(didAsString).toStrictEqual(validDid); | ||
}); | ||
|
||
test('parse and stringify did without type hint', () => { | ||
const didObject: SchemaDid = { | ||
did: 'did', | ||
method: 'schema', | ||
network: Network.NodeIpfs, | ||
hash: '0xa937ea507c396d8d417be352825c65f5fdf1e6fb60e8368db03f2cccda05567c' | ||
} | ||
const validDid = `did:schema:node-ipfs:0xa937ea507c396d8d417be352825c65f5fdf1e6fb60e8368db03f2cccda05567c`; | ||
const resultObject = parseSchemaDid(validDid); | ||
expect(resultObject).toStrictEqual(didObject); | ||
const didAsString = stringifySchemaDid(resultObject); | ||
expect(didAsString).toStrictEqual(validDid); | ||
}); | ||
/** @exports test-did-utils */ |
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