"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

require("../../injector");

var _create = require("../../codec/create");

var _EventRecord = _interopRequireDefault(require("../../json/EventRecord.001.json"));

var _EventRecord2 = _interopRequireDefault(require("../../json/EventRecord.003.json"));

var _Event = _interopRequireDefault(require("../../primitive/Generic/Event"));

var _Metadata = _interopRequireDefault(require("../../Metadata"));

var _static = _interopRequireDefault(require("../../Metadata/v0/static"));

var _static2 = _interopRequireDefault(require("../../Metadata/static"));

// Copyright 2017-2019 @polkadot/types authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
describe('EventRecord', () => {
  describe('EventRecord_0_76', () => {
    beforeEach(() => {
      _Event.default.injectMetadata(new _Metadata.default(_static.default));
    });
    it('decodes correctly', () => {
      const records = (0, _create.createType)('Vec<EventRecord>', _EventRecord.default.params.result.changes[0][1]);
      const er = records[0];
      expect(er.phase.type).toEqual('ApplyExtrinsic');
    });
  });
  describe('EventRecord (current)', () => {
    beforeEach(() => {
      _Event.default.injectMetadata(new _Metadata.default(_static2.default));
    });
    it('decodes older eventrecord correctly', () => {
      const records = (0, _create.createType)('Vec<EventRecord>', _EventRecord.default.params.result.changes[0][1], true);
      const er = records[0];
      expect(er.phase.type).toEqual('ApplyExtrinsic');
    });
    it('decodes eventrecord with topics correctly', () => {
      const hex = _EventRecord2.default.params.result.changes[0][1];
      const records = (0, _create.createType)('Vec<EventRecord>', hex, true);
      const er = records[0];
      expect(er.phase.type).toEqual('ApplyExtrinsic');
      expect(records.toHex()).toEqual(hex);
    });
  });
});