var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
import { expect } from 'chai';
import { signers } from '../../../src/jose/algorithms/signing/signers.js';
import { validateJsonSchema } from '../../../src/schema-validator.js';
const { secp256k1 } = signers;
describe('JwkVerificationMethod', () => __awaiter(void 0, void 0, void 0, function* () {
    if (process.env.TESTSOFF === 'true') {
        return;
    }
    const { publicJwk } = yield secp256k1.generateKeyPair();
    it('should not throw an exception if properly formatted verificationMethod', () => {
        expect(() => validateJsonSchema('JwkVerificationMethod', {
            id: 'did:dwn:alice#key1',
            type: 'JsonWebKey2020',
            controller: 'did:dwn:alice',
            publicKeyJwk: publicJwk
        })).to.not.throw();
    });
    it('should not throw if `id` does not have the DID as prefix', () => {
        expect(() => validateJsonSchema('JwkVerificationMethod', {
            id: '#key1',
            type: 'JsonWebKey2020',
            controller: 'did:dwn:alice',
            publicKeyJwk: publicJwk
        })).to.not.throw();
    });
    it('should throw an exception if id isn\'t a string', () => {
        expect(() => validateJsonSchema('JwkVerificationMethod', {
            id: {},
            type: 'JsonWebKey2020',
            controller: 'did:dwn:alice',
            publicKeyJwk: publicJwk
        })).to.throw('id: must be string');
    });
    it('should throw an exception if controller isn\'t a did', () => {
        expect(() => validateJsonSchema('JwkVerificationMethod', {
            id: 'did:dwn:alice#key1',
            type: 'JsonWebKey2020',
            controller: 'notadid:dwn:alice',
            publicKeyJwk: publicJwk
        })).to.throw('controller: must match pattern');
    });
    it('should throw an exception if publicKeyJwk isn\'t present in verificationMethod', () => {
        expect(() => validateJsonSchema('JwkVerificationMethod', {
            id: 'did:dwn:alice#key1',
            type: 'JsonWebKey2020',
            controller: 'did:dwn:alice'
        })).to.throw('publicKeyJwk');
    });
    it('should throw an exception if publicKeyJwk isn\'t an object', () => {
        expect(() => validateJsonSchema('JwkVerificationMethod', {
            id: 'did:dwn:alice#key1',
            type: 'JsonWebKey2020',
            controller: 'did:dwn:alice',
            publicKeyJwk: 'notAnObject'
        })).to.throw('publicKeyJwk');
    });
}));
//# sourceMappingURL=jwk-verification-method.spec.js.map