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 chaiAsPromised from 'chai-as-promised';
import chai, { expect } from 'chai';
import { DidIonResolver } from '../../src/did/did-ion-resolver.js';
// extends chai to test promises
chai.use(chaiAsPromised);
describe('DidIonResolver', () => {
    if (process.env.TESTSOFF === 'true') {
        return;
    }
    const defaultResolutionEndpoint = 'https://discover.did.msidentity.com/1.0/identifiers/';
    it('should set a default resolution endpoint when none is given in constructor', () => __awaiter(void 0, void 0, void 0, function* () {
        const didIonResolver = new DidIonResolver();
        expect(didIonResolver['resolutionEndpoint']).to.equal(defaultResolutionEndpoint);
    }));
    it('should resolve an ION DID correctly', () => __awaiter(void 0, void 0, void 0, function* () {
        var _a;
        const did = 'did:ion:EiClkZMDxPKqC9c-umQfTkR8vvZ9JPhl_xLDI9Nfk38w5w';
        const didIonResolver = new DidIonResolver();
        const resolutionDocument = yield didIonResolver.resolve(did);
        expect((_a = resolutionDocument.didDocument) === null || _a === void 0 ? void 0 : _a.id).to.equal(did);
        expect(resolutionDocument.didDocumentMetadata.canonicalId).to.equal(did);
    }));
    it('should throw if ION DID cannot be resolved', () => __awaiter(void 0, void 0, void 0, function* () {
        const did = 'did:ion:SomethingThatCannotBeResolved';
        const didIonResolver = new DidIonResolver();
        const resolutionPromise = didIonResolver.resolve(did);
        yield expect(resolutionPromise).to.be.rejectedWith('unable to resolve');
    }));
});
//# sourceMappingURL=did-ion-resolver.spec.js.map