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 { Message } from '../../src/core/message.js';
import { RecordsRead } from '../../src/index.js';
import { TestDataGenerator } from '../utils/test-data-generator.js';
describe('Message', () => {
    if (process.env.TESTSOFF === 'true') {
        return;
    }
    describe('getAuthor()', () => {
        it('should return `undefined` if message is not signed', () => __awaiter(void 0, void 0, void 0, function* () {
            const recordsRead = yield RecordsRead.create({
                recordId: yield TestDataGenerator.randomCborSha256Cid()
            });
            console.log('recordsRead', recordsRead);
            const author = Message.getAuthor(recordsRead.message);
            expect(author).to.be.undefined;
        }));
    });
    describe('toJSON()', () => {
        it('should return the message passed in to the constructor', () => __awaiter(void 0, void 0, void 0, function* () {
            // create a message without `authorization`
            const { message } = yield RecordsRead.create({
                recordId: yield TestDataGenerator.randomCborSha256Cid()
            });
            console.log('message', message);
            // NOTE: parse() calls constructor internally
            const recordsRead = yield RecordsRead.parse(message);
            console.log('recordsRead', recordsRead);
            expect(recordsRead.toJSON()).to.equal(message);
        }));
    });
});
//# sourceMappingURL=message.spec.js.map