summaryrefslogtreecommitdiff
path: root/spec/helpers/device_registration_helper_spec.rb
blob: a8222cddca914f778e6b44afafc0dbc9b4f4f3c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true

require "spec_helper"

RSpec.describe DeviceRegistrationHelper, feature_category: :authentication_and_authorization do
  describe "#device_registration_data" do
    it "returns a hash with device registration properties without initial error" do
      device_registration_data = helper.device_registration_data(
        current_password_required: false,
        target_path: "/my/path",
        webauthn_error: nil
      )

      expect(device_registration_data).to eq(
        {
          initial_error: nil,
          target_path: "/my/path",
          password_required: "false"
        })
    end

    it "returns a hash with device registration properties with initial error" do
      device_registration_data = helper.device_registration_data(
        current_password_required: true,
        target_path: "/my/path",
        webauthn_error: { message: "my error" }
      )

      expect(device_registration_data).to eq(
        {
          initial_error: "my error",
          target_path: "/my/path",
          password_required: "true"
        })
    end
  end
end