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