{"size": 999, "ext": "js", "max_stars_repo_path": "src/__tests__/register-test.js", "max_stars_repo_name": "uport-project/secp256k1-did-resolver", "max_stars_repo_stars_event_min_datetime": "2019-01-29T23:16:29.000Z", "max_stars_repo_stars_event_max_datetime": "2019-01-30T00:03:08.000Z", "max_issues_repo_path": "src/__tests__/register-test.js", "max_issues_repo_name": "uport-project/secp256k1-did-resolver", "max_issues_repo_issues_event_min_datetime": "2019-01-07T06:49:26.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-07T06:49:26.000Z", "max_forks_repo_path": "src/__tests__/register-test.js", "max_forks_repo_name": "uport-project/secp256k1-did-resolver", "max_forks_repo_forks_event_min_datetime": "2022-03-28T11:57:38.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T11:57:38.000Z"}
{"max_stars_count": 2, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 30.2727272727, "max_line_length": 183, "alphanum_fraction": 0.6036036036}
import resolve from 'did-resolver'
import register from '../register'

describe('secp256k1Resolver', () => {
  register()
  describe('resolve', () => {
    describe('valid DID docs', () => {
      const publicKey = '03fdd57adec3d438ea237fe46b33ee1e016eda6b585c3e27ea66686c2ea5358479'
      const did = `did:secp256k1:${publicKey}`
      const didDoc = {
        '@context': 'https://w3id.org/did/v1',
        id: did,
        publicKey: [{
          id: `${did}#keys-1`,
          type: 'Secp256k1VerificationKey2018',
          owner: did,
          publicKeyHex: publicKey
        }]
      }

      it('resolves document', async () => {
        expect(resolve(did)).resolves.toEqual(didDoc)
      })
    })

    describe('error handling', () => {
      it('rejects promise', async () => {
        expect(resolve('did:secp256k1:2nQtiQG6Cgm1GYTBaaKAgr76uY7iSexUkqX')).rejects.toEqual(new Error('Not a valid secp256k1 DID: did:secp256k1:2nQtiQG6Cgm1GYTBaaKAgr76uY7iSexUkqX'))
      })
    })
  })
})
