{"size": 1105, "ext": "js", "max_stars_repo_path": "test/unit/specs/store/ledger.spec.js", "max_stars_repo_name": "Forkbox/lunie", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/unit/specs/store/ledger.spec.js", "max_issues_repo_name": "Forkbox/lunie", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/unit/specs/store/ledger.spec.js", "max_forks_repo_name": "Forkbox/lunie", "max_forks_repo_forks_event_min_datetime": "2019-06-15T19:07:48.000Z", "max_forks_repo_forks_event_max_datetime": "2019-06-15T19:07:48.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 24.0217391304, "max_line_length": 71, "alphanum_fraction": 0.5303167421}
import ledgerModule from "modules/ledger.js"

jest.mock("@lunie/cosmos-keys", () => ({}))

describe(`Module: Ledger`, () => {
  let module, state, actions

  beforeEach(() => {
    module = ledgerModule()
    state = module.state
    actions = module.actions
  })

  describe(`Actions`, () => {
    describe(`connect ledger`, () => {
      it(`successfully logs in with Ledger Nano`, async () => {
        const commit = jest.fn()
        state.externals.Ledger = class MockLedger {
          getCosmosAddress() {
            return "cosmos1"
          }
        }
        const res = await actions.connectLedgerApp({
          commit,
          state
        })
        expect(res).toBe("cosmos1")
      })

      it(`start the Ledger address confirmation process`, async () => {
        const spy = jest.fn()
        state.externals.Ledger = class MockLedger {
          async confirmLedgerAddress() {
            spy()
          }
        }
        // does not throw
        await actions.confirmLedgerAddress({
          state
        })
        expect(spy).toHaveBeenCalled()
      })
    })
  })
})
