discourse/spec/components/wizard/wizard_step_spec.rb

26 lines
676 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'rails_helper'
require 'wizard'
describe Wizard::Step do
let(:wizard) { Wizard.new(Fabricate.build(:user)) }
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')
2017-07-27 21:20:09 -04:00
dropdown.add_choice('nachos', data: { color: 'yellow' })
2016-09-07 18:04:01 -04:00
dropdown.add_choice('pizza', label: 'Pizza!')
expect(step.fields).to eq([text, dropdown])
2016-09-07 18:04:01 -04:00
expect(dropdown.choices.size).to eq(3)
end
end