2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-31 13:35:49 -04:00
|
|
|
require "wizard"
|
|
|
|
|
2022-07-27 22:27:38 -04:00
|
|
|
RSpec.describe Wizard::Step do
|
2016-09-12 14:43:00 -04:00
|
|
|
let(:wizard) { Wizard.new(Fabricate.build(:user)) }
|
2016-08-31 13:35:49 -04:00
|
|
|
let(:step) { wizard.create_step("test-step") }
|
|
|
|
|
|
|
|
it "supports fields and options" do
|
|
|
|
expect(step.fields).to be_empty
|
|
|
|
text = step.add_field(id: "test", type: "text")
|
|
|
|
expect(step.fields).to eq([text])
|
|
|
|
|
|
|
|
dropdown = step.add_field(id: "snacks", type: "dropdown")
|
2016-09-07 18:04:01 -04:00
|
|
|
dropdown.add_choice("candy")
|
|
|
|
dropdown.add_choice("nachos", data: { color: "yellow" })
|
|
|
|
dropdown.add_choice("pizza", label: "Pizza!")
|
2016-08-31 13:35:49 -04:00
|
|
|
expect(step.fields).to eq([text, dropdown])
|
2016-09-07 18:04:01 -04:00
|
|
|
expect(dropdown.choices.size).to eq(3)
|
2022-08-14 20:22:07 -04:00
|
|
|
|
|
|
|
checkbox = step.add_field(id: "foobar", type: "checkbox", disabled: true)
|
|
|
|
expect(step.fields).to eq([text, dropdown, checkbox])
|
|
|
|
expect(checkbox.disabled).to eq(true)
|
2016-08-31 13:35:49 -04:00
|
|
|
end
|
|
|
|
end
|