text: // Generated by BUCKLESCRIPT VERSION 5.0.6, PLEASE EDIT WITH CARE
  'use strict';
  
  var Jest = require("@glennsl/bs-jest/src/jest.js");
  var $$Event = require("../../src/application/events/Event.bs.js");
  var Generators = require("../helpers/Generators.bs.js");
  var WalletTypes = require("../../src/application/wallet/WalletTypes.bs.js");
  var PrimitiveTypes = require("../../src/application/PrimitiveTypes.bs.js");
  var AccountKeyChain = require("../../src/application/wallet/AccountKeyChain.bs.js");
  var ValidationHelpers = require("../helpers/ValidationHelpers.bs.js");
  var Venture__Validation = require("../../src/application/Venture__Validation.bs.js");
  
  Jest.describe(" AccountKeyChainIdentified", (function (param) {
          Jest.describe("when everything is fine", (function (param) {
                  var match = Generators.twoUserSessions(/* () */0);
                  var user1 = match[0];
                  var log = Generators.Log[/* withCustodianKeyChain */38](undefined, undefined, undefined, user1, Generators.Log[/* withCustodian */33](user1, /* :: */[
                            user1,
                            /* [] */0
                          ], Generators.Log[/* withAccount */27](user1, Generators.Log[/* withFirstPartner */18](user1)(Generators.Log[/* createVenture */11](user1)))));
                  return ValidationHelpers.testValidationResult(undefined, ValidationHelpers.constructState(undefined, log), Generators.Log[/* lastItem */4](Generators.Log[/* withAccountKeyChainIdentified */39](undefined, log)), /* Ok */0);
                }));
          Jest.describe("when the account doesn't exist", (function (param) {
                  var match = Generators.twoUserSessions(/* () */0);
                  var user1 = match[0];
                  var log = Generators.Log[/* withCustodianKeyChain */38](undefined, undefined, undefined, user1, Generators.Log[/* withCustodian */33](user1, /* :: */[
                            user1,
                            /* [] */0
                          ], Generators.Log[/* withAccount */27](user1, Generators.Log[/* withFirstPartner */18](user1)(Generators.Log[/* createVenture */11](user1)))));
                  var identified = $$Event.getAccountKeyChainIdentifiedExn(Generators.Log[/* lastEvent */5](Generators.Log[/* withAccountKeyChainIdentified */39](undefined, log)));
                  var init = identified[/* keyChain */0];
                  return ValidationHelpers.testDataValidation((function (param, param$1) {
                                return ValidationHelpers.withSystemIssuer(Venture__Validation.validateAccountKeyChainIdentified, param, param$1);
                              }), ValidationHelpers.constructState(undefined, log), /* record */[/* keyChain : record */[
                                /* accountIdx */WalletTypes.AccountIndex[/* fromInt */1](1),
                                /* identifier */init[/* identifier */1],
                                /* nCoSigners */init[/* nCoSigners */2],
                                /* sequence */init[/* sequence */3],
                                /* custodianKeyChains */init[/* custodianKeyChains */4]
                              ]], /* BadData */["Account doesn't exist"]);
                }));
          Jest.describe("when the AccountKeyChain is inconsistent", (function (param) {
                  var match = Generators.twoUserSessions(/* () */0);
                  var user1 = match[0];
                  var log = Generators.Log[/* withCustodianKeyChain */38](undefined, undefined, undefined, user1, Generators.Log[/* withCustodian */33](user1, /* :: */[
                            user1,
                            /* [] */0
                          ], Generators.Log[/* withAccount */27](user1, Generators.Log[/* withFirstPartner */18](user1)(Generators.Log[/* createVenture */11](user1)))));
                  var identified = $$Event.getAccountKeyChainIdentifiedExn(Generators.Log[/* lastEvent */5](Generators.Log[/* withAccountKeyChainIdentified */39](undefined, log)));
                  var init = identified[/* keyChain */0];
                  return ValidationHelpers.testDataValidation((function (param, param$1) {
                                return ValidationHelpers.withSystemIssuer(Venture__Validation.validateAccountKeyChainIdentified, param, param$1);
                              }), ValidationHelpers.constructState(undefined, log), /* record */[/* keyChain : record */[
                                /* accountIdx */init[/* accountIdx */0],
                                /* identifier */"",
                                /* nCoSigners */init[/* nCoSigners */2],
                                /* sequence */init[/* sequence */3],
                                /* custodianKeyChains */init[/* custodianKeyChains */4]
                              ]], /* BadData */["Inconsistent AccountKeyChain"]);
                }));
          return Jest.describe("when a CustodianKeyChain is unknown", (function (param) {
                        var match = Generators.twoUserSessions(/* () */0);
                        var user1 = match[0];
                        var log = Generators.Log[/* withCustodianKeyChain */38](undefined, undefined, undefined, user1, Generators.Log[/* withCustodian */33](user1, /* :: */[
                                  user1,
                                  /* [] */0
                                ], Generators.Log[/* withAccount */27](user1, Generators.Log[/* withFirstPartner */18](user1)(Generators.Log[/* createVenture */11](user1)))));
                        return ValidationHelpers.testDataValidation((function (param, param$1) {
                                      return ValidationHelpers.withSystemIssuer(Venture__Validation.validateAccountKeyChainIdentified, param, param$1);
                                    }), ValidationHelpers.constructState(undefined, log), /* record */[/* keyChain */AccountKeyChain.make(undefined, WalletTypes.AccountIndex[/* default */11], /* :: */[
                                          /* tuple */[
                                            user1[/* userId */0],
                                            Generators.custodianKeyChain(undefined, undefined, PrimitiveTypes.VentureId[/* make */10](/* () */0), 1, user1)
                                          ],
                                          /* [] */0
                                        ])], /* BadData */["Bad CustodianKeyChain"]);
                      }));
        }));
  
  Jest.describe("AccountKeyChainActivated", (function (param) {
          Jest.describe("when everything is fine", (function (param) {
                  var match = Generators.twoUserSessions(/* () */0);
                  var user1 = match[0];
                  var eta = Generators.Log[/* withCustodianKeyChain */38](undefined, undefined, undefined, user1, Generators.Log[/* withCustodian */33](user1, /* :: */[
                            user1,
                            /* [] */0
                          ], Generators.Log[/* withAccount */27](user1, Generators.Log[/* withFirstPartner */18](user1)(Generators.Log[/* createVenture */11](user1)))));
                  var log = Generators.Log[/* withAccountKeyChainIdentified */39](undefined, eta);
                  return ValidationHelpers.testValidationResult(undefined, ValidationHelpers.constructState(undefined, log), Generators.Log[/* lastItem */4](Generators.Log[/* withAccountKeyChainActivated */40](undefined, user1, log)), /* Ok */0);
                }));
          Jest.describe("after a partner removal", (function (param) {
                  var match = Generators.twoUserSessions(/* () */0);
                  var user2 = match[1];
                  var user1 = match[0];
                  var eta = Generators.Log[/* withCustodianKeyChain */38](undefined, undefined, undefined, user1, Generators.Log[/* withCustodian */33](user1, /* :: */[
                            user1,
                            /* [] */0
                          ], Generators.Log[/* withAccount */27](user1, Generators.Log[/* withFirstPartner */18](user1)(Generators.Log[/* createVenture */11](user1)))));
                  var eta$1 = Generators.Log[/* withCustodianKeyChain */38](undefined, undefined, undefined, user2, Generators.Log[/* withCustodian */33](user2, /* :: */[
                            user1,
                            /* :: */[
                              user2,
                              /* [] */0
                            ]
                          ], Generators.Log[/* withPartner */17](undefined, user2, /* :: */[
                                user1,
                                /* [] */0
                              ], Generators.Log[/* withAccountKeyChainActivated */40](undefined, user1, Generators.Log[/* withAccountKeyChainIdentified */39](undefined, eta)))));
                  var log = Generators.Log[/* withPartnerRemoved */23](user2, /* :: */[
                        user1,
                        /* [] */0
                      ], Generators.Log[/* withAccountKeyChainActivated */40](undefined, user1, Generators.Log[/* withAccountKeyChainActivated */40](undefined, user2, Generators.Log[/* withAccountKeyChainIdentified */39](undefined, eta$1))));
                  return ValidationHelpers.testValidationResult(undefined, ValidationHelpers.constructState(undefined, log), Generators.Log[/* lastItem */4](Generators.Log[/* withAccountKeyChainActivated */40](1, user1, log)), /* Ok */0);
                }));
          Jest.describe("when the account doesn't exist", (function (param) {
                  var match = Generators.twoUserSessions(/* () */0);
                  var user1 = match[0];
                  var eta = Generators.Log[/* withCustodianKeyChain */38](undefined, undefined, undefined, user1, Generators.Log[/* withCustodian */33](user1, /* :: */[
                            user1,
                            /* [] */0
                          ], Generators.Log[/* withAccount */27](user1, Generators.Log[/* withFirstPartner */18](user1)(Generators.Log[/* createVenture */11](user1)))));
                  var log = Generators.Log[/* withAccountKeyChainIdentified */39](undefined, eta);
                  var activated = $$Event.getAccountKeyChainActivatedExn(Generators.Log[/* lastEvent */5](Generators.Log[/* withAccountKeyChainActivated */40](undefined, user1, log)));
                  return ValidationHelpers.testDataValidation((function (param, param$1) {
                                return ValidationHelpers.withIssuer(user1, Venture__Validation.validateAccountKeyChainActivated, param, param$1);
                              }), ValidationHelpers.constructState(undefined, log), /* record */[
                              /* accountIdx */WalletTypes.AccountIndex[/* fromInt */1](1),
                              /* custodianId */activated[/* custodianId */1],
                              /* identifier */activated[/* identifier */2],
                              /* sequence */activated[/* sequence */3]
                            ], /* BadData */["Account doesn't exist"]);
                }));
          Jest.describe("when the issuer doesn't match", (function (param) {
                  var match = Generators.twoUserSessions(/* () */0);
                  var user2 = match[1];
                  var user1 = match[0];
                  var eta = Generators.Log[/* withCustodianKeyChain */38](undefined, undefined, undefined, user1, Generators.Log[/* withCustodian */33](user1, /* :: */[
                            user1,
                            /* [] */0
                          ], Generators.Log[/* withAccount */27](user1, Generators.Log[/* withFirstPartner */18](user1)(Generators.Log[/* createVenture */11](user1)))));
                  var log = Generators.Log[/* withPartner */17](undefined, user2, /* :: */[
                        user1,
                        /* [] */0
                      ], Generators.Log[/* withAccountKeyChainIdentified */39](undefined, eta));
                  var activated = $$Event.getAccountKeyChainActivatedExn(Generators.Log[/* lastEvent */5](Generators.Log[/* withAccountKeyChainActivated */40](undefined, user1, log)));
                  return ValidationHelpers.testDataValidation((function (param, param$1) {
                                return ValidationHelpers.withIssuer(user2, Venture__Validation.validateAccountKeyChainActivated, param, param$1);
                              }), ValidationHelpers.constructState(undefined, log), activated, /* InvalidIssuer */2);
                }));
          Jest.describe("when the issuer is not a custodian", (function (param) {
                  var match = Generators.twoUserSessions(/* () */0);
                  var user2 = match[1];
                  var user1 = match[0];
                  var eta = Generators.Log[/* withCustodianKeyChain */38](undefined, undefined, undefined, user1, Generators.Log[/* withCustodian */33](user1, /* :: */[
                            user1,
                            /* [] */0
                          ], Generators.Log[/* withAccount */27](user1, Generators.Log[/* withFirstPartner */18](user1)(Generators.Log[/* createVenture */11](user1)))));
                  var log = Generators.Log[/* withPartner */17](undefined, user2, /* :: */[
                        user1,
                        /* [] */0
                      ], Generators.Log[/* withAccountKeyChainIdentified */39](undefined, eta));
                  var activated = $$Event.getAccountKeyChainActivatedExn(Generators.Log[/* lastEvent */5](Generators.Log[/* withAccountKeyChainActivated */40](undefined, user2, log)));
                  return ValidationHelpers.testDataValidation((function (param, param$1) {
                                return ValidationHelpers.withIssuer(user2, Venture__Validation.validateAccountKeyChainActivated, param, param$1);
                              }), ValidationHelpers.constructState(undefined, log), activated, /* BadData */["Not a custodian"]);
                }));
          Jest.describe("when the identifier is unknown", (function (param) {
                  var match = Generators.twoUserSessions(/* () */0);
                  var user1 = match[0];
                  var eta = Generators.Log[/* withCustodianKeyChain */38](undefined, undefined, undefined, user1, Generators.Log[/* withCustodian */33](user1, /* :: */[
                            user1,
                            /* [] */0
                          ], Generators.Log[/* withAccount */27](user1, Generators.Log[/* withFirstPartner */18](user1)(Generators.Log[/* createVenture */11](user1)))));
                  var log = Generators.Log[/* withAccountKeyChainIdentified */39](undefined, eta);
                  var activated = $$Event.getAccountKeyChainActivatedExn(Generators.Log[/* lastEvent */5](Generators.Log[/* withAccountKeyChainActivated */40](undefined, user1, log)));
                  return ValidationHelpers.testDataValidation((function (param, param$1) {
                                return ValidationHelpers.withIssuer(user1, Venture__Validation.validateAccountKeyChainActivated, param, param$1);
                              }), ValidationHelpers.constructState(undefined, log), /* record */[
                              /* accountIdx */activated[/* accountIdx */0],
                              /* custodianId */activated[/* custodianId */1],
                              /* identifier */"bad",
                              /* sequence */activated[/* sequence */3]
                            ], /* BadData */["Unknown AccountKeyChain identifier"]);
                }));
          return Jest.describe("when the sequence is not in order", (function (param) {
                        var match = Generators.twoUserSessions(/* () */0);
                        var user1 = match[0];
                        var eta = Generators.Log[/* withCustodianKeyChain */38](undefined, undefined, undefined, user1, Generators.Log[/* withCustodian */33](user1, /* :: */[
                                  user1,
                                  /* [] */0
                                ], Generators.Log[/* withAccount */27](user1, Generators.Log[/* withFirstPartner */18](user1)(Generators.Log[/* createVenture */11](user1)))));
                        var log = Generators.Log[/* withAccountKeyChainIdentified */39](undefined, eta);
                        var activated = $$Event.getAccountKeyChainActivatedExn(Generators.Log[/* lastEvent */5](Generators.Log[/* withAccountKeyChainActivated */40](undefined, user1, log)));
                        return ValidationHelpers.testDataValidation((function (param, param$1) {
                                      return ValidationHelpers.withIssuer(user1, Venture__Validation.validateAccountKeyChainActivated, param, param$1);
                                    }), ValidationHelpers.constructState(undefined, log), /* record */[
                                    /* accountIdx */activated[/* accountIdx */0],
                                    /* custodianId */activated[/* custodianId */1],
                                    /* identifier */activated[/* identifier */2],
                                    /* sequence */1
                                  ], /* BadData */["AccountKeyChain sequence out of order"]);
                      }));
        }));
  
  /*  Not a pure module */
  