fron-ui 1.0.0rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +38 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/.yardopts +8 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +105 -0
- data/Rakefile +37 -0
- data/Readme.md +4 -0
- data/db.json +192 -0
- data/fron-ui.gemspec +21 -0
- data/lib/fron-ui.rb +1 -0
- data/lib/fron_ui.rb +5 -0
- data/lib/fron_ui/version.rb +7 -0
- data/opal/fron-ui/base.rb +49 -0
- data/opal/fron-ui/behaviors/action.rb +40 -0
- data/opal/fron-ui/behaviors/actions.rb +40 -0
- data/opal/fron-ui/behaviors/confirmation.rb +23 -0
- data/opal/fron-ui/behaviors/dropdown.rb +27 -0
- data/opal/fron-ui/behaviors/file.rb +48 -0
- data/opal/fron-ui/behaviors/intendable_children.rb +76 -0
- data/opal/fron-ui/behaviors/keydown.rb +31 -0
- data/opal/fron-ui/behaviors/loop.rb +41 -0
- data/opal/fron-ui/behaviors/render.rb +30 -0
- data/opal/fron-ui/behaviors/rest.rb +121 -0
- data/opal/fron-ui/behaviors/selectable_children.rb +67 -0
- data/opal/fron-ui/behaviors/serialize.rb +32 -0
- data/opal/fron-ui/behaviors/shortcuts.rb +35 -0
- data/opal/fron-ui/behaviors/state.rb +56 -0
- data/opal/fron-ui/behaviors/transition.rb +63 -0
- data/opal/fron-ui/components/action.rb +18 -0
- data/opal/fron-ui/components/box.rb +17 -0
- data/opal/fron-ui/components/button.rb +61 -0
- data/opal/fron-ui/components/calendar.rb +129 -0
- data/opal/fron-ui/components/checkbox.rb +57 -0
- data/opal/fron-ui/components/chooser.rb +246 -0
- data/opal/fron-ui/components/color_panel.rb +235 -0
- data/opal/fron-ui/components/color_picker.rb +111 -0
- data/opal/fron-ui/components/container.rb +61 -0
- data/opal/fron-ui/components/date_picker.rb +141 -0
- data/opal/fron-ui/components/drag.rb +76 -0
- data/opal/fron-ui/components/dropdown.rb +72 -0
- data/opal/fron-ui/components/icon.rb +29 -0
- data/opal/fron-ui/components/image.rb +77 -0
- data/opal/fron-ui/components/input.rb +30 -0
- data/opal/fron-ui/components/label.rb +9 -0
- data/opal/fron-ui/components/list.rb +34 -0
- data/opal/fron-ui/components/loader.rb +63 -0
- data/opal/fron-ui/components/modal.rb +0 -0
- data/opal/fron-ui/components/notifications.rb +73 -0
- data/opal/fron-ui/components/number.rb +202 -0
- data/opal/fron-ui/components/progress.rb +52 -0
- data/opal/fron-ui/components/slider.rb +47 -0
- data/opal/fron-ui/components/tabs.rb +149 -0
- data/opal/fron-ui/components/textarea.rb +13 -0
- data/opal/fron-ui/components/time.rb +65 -0
- data/opal/fron-ui/components/title.rb +34 -0
- data/opal/fron-ui/examples/blog/index.rb +289 -0
- data/opal/fron-ui/examples/comments/components/comment.rb +75 -0
- data/opal/fron-ui/examples/comments/components/comments.rb +93 -0
- data/opal/fron-ui/examples/comments/components/footer.rb +36 -0
- data/opal/fron-ui/examples/comments/components/header.rb +35 -0
- data/opal/fron-ui/examples/comments/components/list.rb +12 -0
- data/opal/fron-ui/examples/comments/index.rb +6 -0
- data/opal/fron-ui/examples/contacts/components/contacts.rb +100 -0
- data/opal/fron-ui/examples/contacts/components/details.rb +92 -0
- data/opal/fron-ui/examples/contacts/components/item.rb +46 -0
- data/opal/fron-ui/examples/contacts/components/list.rb +10 -0
- data/opal/fron-ui/examples/contacts/components/sidebar.rb +30 -0
- data/opal/fron-ui/examples/contacts/index.rb +6 -0
- data/opal/fron-ui/examples/editor/index.rb +164 -0
- data/opal/fron-ui/examples/kitchensink/index.rb +193 -0
- data/opal/fron-ui/examples/todos/components/item.rb +84 -0
- data/opal/fron-ui/examples/todos/components/options.rb +26 -0
- data/opal/fron-ui/examples/todos/components/todos.rb +145 -0
- data/opal/fron-ui/examples/todos/index.rb +6 -0
- data/opal/fron-ui/examples/webshop/index.rb +0 -0
- data/opal/fron-ui/fonts/ionicons.rb +2954 -0
- data/opal/fron-ui/fonts/open_sans.rb +19 -0
- data/opal/fron-ui/lib/collection.rb +138 -0
- data/opal/fron-ui/lib/date.rb +23 -0
- data/opal/fron-ui/lib/debounce.rb +14 -0
- data/opal/fron-ui/lib/image_loader.rb +13 -0
- data/opal/fron-ui/lib/lorem.rb +93 -0
- data/opal/fron-ui/lib/nil.rb +29 -0
- data/opal/fron-ui/lib/record.rb +23 -0
- data/opal/fron-ui/lib/state_serializer.rb +129 -0
- data/opal/fron-ui/lib/storage.rb +57 -0
- data/opal/fron-ui/spec/setup.rb +40 -0
- data/opal/fron-ui/ui.rb +40 -0
- data/opal/fron-ui/utils/theme_roller.rb +63 -0
- data/opal/fron-ui/vendor/autoprefixer.js +21114 -0
- data/opal/fron-ui/vendor/marked.js +1291 -0
- data/opal/fron-ui/vendor/md5.js +274 -0
- data/opal/fron-ui/vendor/moment.js +3083 -0
- data/opal/fron-ui/vendor/uuid.js +92 -0
- data/opal/fron_ui.rb +13 -0
- data/spec/behaviors/action_spec.rb +34 -0
- data/spec/behaviors/actions_spec.rb +38 -0
- data/spec/behaviors/confirmation_spec.rb +23 -0
- data/spec/behaviors/dropdown_spec.rb +32 -0
- data/spec/behaviors/render_spec.rb +20 -0
- data/spec/behaviors/rest_spec.rb +70 -0
- data/spec/behaviors/selectable_children_spec.rb +40 -0
- data/spec/behaviors/serialize_spec.rb +34 -0
- data/spec/components/action_spec.rb +7 -0
- data/spec/components/base_spec.rb +19 -0
- data/spec/components/box_spec.rb +7 -0
- data/spec/components/button_spec.rb +9 -0
- data/spec/components/calendar_spec.rb +58 -0
- data/spec/components/checkbox_spec.rb +20 -0
- data/spec/components/chooser_spec.rb +75 -0
- data/spec/components/color_panel_spec.rb +49 -0
- data/spec/components/color_picker_spec.rb +41 -0
- data/spec/components/container_spec.rb +23 -0
- data/spec/components/date_picker_spec.rb +71 -0
- data/spec/components/drag_spec.rb +20 -0
- data/spec/components/dropdown_spec.rb +33 -0
- data/spec/components/image_spec.rb +33 -0
- data/spec/components/input_spec.rb +8 -0
- data/spec/components/list_spec.rb +10 -0
- data/spec/components/loader_spec.rb +9 -0
- data/spec/components/notifications_spec.rb +17 -0
- data/spec/components/number_spec.rb +64 -0
- data/spec/components/progress_spec.rb +23 -0
- data/spec/components/slider_spec.rb +25 -0
- data/spec/components/tabs_spec.rb +50 -0
- data/spec/components/textarea_spec.rb +7 -0
- data/spec/components/time_spec.rb +37 -0
- data/spec/components/title_spec.rb +11 -0
- data/spec/examples/comments_spec.rb +72 -0
- data/spec/examples/todos_spec.rb +39 -0
- data/spec/lib/collection_spec.rb +38 -0
- data/spec/lib/lorem_spec.rb +55 -0
- data/spec/lib/state_serializer_spec.rb +58 -0
- data/spec/lib/storage_spec.rb +39 -0
- data/spec/spec_helper.rb +1 -0
- metadata +223 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe UI::Calendar do
|
|
4
|
+
before do
|
|
5
|
+
allow(Date).to receive(:today).and_return Date.parse('2015-05-01')
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
context 'This year' do
|
|
9
|
+
it 'should display the active month name' do
|
|
10
|
+
expect(subject.header.label.text).to equal('May')
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context 'Next year' do
|
|
15
|
+
before do
|
|
16
|
+
subject.render(Date.parse('2016-05-01'))
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'should display the active month name and year' do
|
|
20
|
+
expect(subject.header.label.text).to equal('May 2016')
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context 'Table' do
|
|
25
|
+
let(:cells) { subject.find_all('tbody td').map(&:text) }
|
|
26
|
+
let(:padding) { 4 }
|
|
27
|
+
|
|
28
|
+
it 'should display days' do
|
|
29
|
+
cells[padding..-1].count.should eq 31
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'should pad cells' do
|
|
33
|
+
cells[0...padding].should eq ['', '', '', '']
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
context 'Clicking on the next month icon' do
|
|
38
|
+
it 'should render the next month' do
|
|
39
|
+
expect {
|
|
40
|
+
subject.find('[action=next_month]').trigger :click
|
|
41
|
+
}.to change { subject.header.label.text }.from('May').to('June')
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
context 'Clicking on the previous month icon' do
|
|
46
|
+
it 'should render the previous month' do
|
|
47
|
+
expect {
|
|
48
|
+
subject.find('[action=prev_month]').trigger :click
|
|
49
|
+
}.to change { subject.header.label.text }.from('May').to('April')
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe '#render' do
|
|
54
|
+
it 'should yield for every day' do
|
|
55
|
+
expect { |b| subject.render(&b) }.to yield_control.exactly(31).times
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe UI::Checkbox do
|
|
4
|
+
it 'should have tabindex' do
|
|
5
|
+
subject[:tabindex].should eq '0'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe '#action' do
|
|
9
|
+
it 'should toggle' do
|
|
10
|
+
expect {
|
|
11
|
+
subject.action
|
|
12
|
+
}.to change { subject.checked }.from(false).to(true)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'should trigger change' do
|
|
16
|
+
expect(subject).to receive(:trigger).with :change
|
|
17
|
+
subject.action
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe UI::Chooser do
|
|
4
|
+
before do
|
|
5
|
+
subject.items = [{ id: 0, value: 'Test' }, { id: 1, value: 'Asd' }]
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it 'should render items' do
|
|
9
|
+
subject.find_all('ui-chooser-item').count.should eq 2
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context 'Focusing the input' do
|
|
13
|
+
let(:expectation) { expect { subject.input.trigger :focus } }
|
|
14
|
+
|
|
15
|
+
it 'should set focused attribute' do
|
|
16
|
+
expectation.to change { subject.attribute?(:focused) }.from(false).to(true)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'should empty the input' do
|
|
20
|
+
subject.input.value = 'test'
|
|
21
|
+
expectation.to change { subject.input.value }.from('test').to(nil)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context 'Bluring the input' do
|
|
26
|
+
let(:expectation) { expect { subject.input.trigger :blur } }
|
|
27
|
+
|
|
28
|
+
it 'should remove focused attribute' do
|
|
29
|
+
subject[:focused] = true
|
|
30
|
+
expectation.to change { subject.attribute?(:focused) }.from(true).to(false)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'should update the input field' do
|
|
34
|
+
subject.select_first
|
|
35
|
+
subject.input.value = ''
|
|
36
|
+
expectation.to change { subject.input.value }.from(nil).to('Test')
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context 'Selecting inteded item' do
|
|
41
|
+
it 'should select it' do
|
|
42
|
+
expect {
|
|
43
|
+
subject.intend_next
|
|
44
|
+
subject.select_intended
|
|
45
|
+
subject.intend_previous
|
|
46
|
+
}.to change { subject.value }.from(nil).to('Test')
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe '#value' do
|
|
51
|
+
context 'Nothing selected' do
|
|
52
|
+
it 'should return nil' do
|
|
53
|
+
subject.value.should eq nil
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
context 'One selected' do
|
|
58
|
+
it 'should return single value' do
|
|
59
|
+
expect {
|
|
60
|
+
subject.select_first
|
|
61
|
+
}.to change { subject.value }.from(nil).to('Test')
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
context 'Multiple selected' do
|
|
66
|
+
it 'should return single value' do
|
|
67
|
+
expect {
|
|
68
|
+
subject.multiple = true
|
|
69
|
+
subject.select_last
|
|
70
|
+
subject.select_first
|
|
71
|
+
}.to change { subject.value }.from(nil).to(%w(Test Asd))
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe UI::ColorPanel do
|
|
4
|
+
it 'should have a default value' do
|
|
5
|
+
subject.color.hex.should eq 'ffffff'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
context 'Changing the fields' do
|
|
9
|
+
it 'should update the color' do
|
|
10
|
+
expect(subject.hued).to receive(:value_y).and_return 0.5
|
|
11
|
+
expect(subject.recta).to receive(:value_y).and_return 0.5
|
|
12
|
+
expect(subject.recta).to receive(:value_x).and_return 0.5
|
|
13
|
+
|
|
14
|
+
subject.hued.trigger :change
|
|
15
|
+
|
|
16
|
+
subject.hue.should eq 180
|
|
17
|
+
subject.saturation.should eq 50
|
|
18
|
+
subject.value.should eq 50
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe '#hue=' do
|
|
23
|
+
it 'should set the value_y of hued' do
|
|
24
|
+
subject.hued.should receive(:value_y=).with(0.5)
|
|
25
|
+
subject.hue = 180
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe '#value=' do
|
|
30
|
+
it 'should set the value_y of rect' do
|
|
31
|
+
subject.recta.should receive(:value_y=).with(0.5)
|
|
32
|
+
subject.value = 50
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe '#saturation=' do
|
|
37
|
+
it 'should set the value_y of rect' do
|
|
38
|
+
subject.recta.should receive(:value_x=).with(0.5)
|
|
39
|
+
subject.saturation = 50
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe '#color=' do
|
|
44
|
+
it 'should set color from CSS' do
|
|
45
|
+
subject.color = :red
|
|
46
|
+
subject.color.hex.should eq 'ff0000'
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe UI::ColorPicker do
|
|
4
|
+
it 'should have a default value' do
|
|
5
|
+
subject.value.should eq '#FFFFFF'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe '#value=' do
|
|
9
|
+
context 'Valid' do
|
|
10
|
+
it 'should set the value' do
|
|
11
|
+
expect {
|
|
12
|
+
subject.value = :orangered
|
|
13
|
+
}.to change { subject.input.value }.from('#FFFFFF').to(:orangered)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context 'Invalid' do
|
|
18
|
+
it 'should_not set the value' do
|
|
19
|
+
expect {
|
|
20
|
+
subject.value = :asd
|
|
21
|
+
}.to change { subject.input.value }.from('#FFFFFF').to('rgba(255,255,255,0.0)')
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
context 'Focusing on the input' do
|
|
27
|
+
it 'should update the dropdown' do
|
|
28
|
+
subject.should receive(:update_dropdown)
|
|
29
|
+
subject.input.trigger :focus
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context 'Setting value' do
|
|
34
|
+
it 'should update dropdown' do
|
|
35
|
+
expect {
|
|
36
|
+
subject.input.value = :orangered
|
|
37
|
+
subject.input.trigger :change
|
|
38
|
+
}.to change { subject.input.value }.from('#FFFFFF').to(:orangered)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe UI::Container do
|
|
4
|
+
it 'should set defaults' do
|
|
5
|
+
subject.direction.should eq :column
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe '#compact' do
|
|
9
|
+
context 'false' do
|
|
10
|
+
it 'should remvoe compact attribute' do
|
|
11
|
+
subject.compact = false
|
|
12
|
+
expect {
|
|
13
|
+
subject.compact = true
|
|
14
|
+
}.to change { subject.attribute?(:compact) }.from(false).to(true)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
context 'true' do
|
|
19
|
+
it 'should add compact attribute' do
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe UI::DatePicker do
|
|
4
|
+
before do
|
|
5
|
+
allow(Date).to receive(:today).and_return Date.parse('2015-01-01')
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it 'should set default value' do
|
|
9
|
+
subject.value.should eq Date.today
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'should set selected td' do
|
|
13
|
+
subject.find('.selected')[:date].should eq '2015-01-01'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
context 'Focusing the input' do
|
|
17
|
+
it 'should render the dropdown' do
|
|
18
|
+
subject.should receive(:render)
|
|
19
|
+
subject.input.trigger :focus
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
context 'Changing the input' do
|
|
24
|
+
it 'should set the value' do
|
|
25
|
+
expect {
|
|
26
|
+
subject.input.value = '2015-05-05'
|
|
27
|
+
subject.input.trigger :change
|
|
28
|
+
}.to change { subject.find('.selected')[:date] }.from('2015-01-01').to('2015-05-05')
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context 'Pressing down' do
|
|
33
|
+
it 'should select next day' do
|
|
34
|
+
expect {
|
|
35
|
+
subject.trigger :keydown, keyCode: 40, shiftKey: false
|
|
36
|
+
}.to change { subject.value }.from(Date.today).to(Date.today + 1)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context 'Pressing down with shift' do
|
|
41
|
+
it 'should select next day' do
|
|
42
|
+
expect {
|
|
43
|
+
subject.trigger :keydown, keyCode: 40, shiftKey: true
|
|
44
|
+
}.to change { subject.value }.from(Date.today).to(Date.today.next_month)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
context 'Pressing up' do
|
|
49
|
+
it 'should select next day' do
|
|
50
|
+
expect {
|
|
51
|
+
subject.trigger :keydown, keyCode: 38, shiftKey: false
|
|
52
|
+
}.to change { subject.value }.from(Date.today).to(Date.today - 1)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context 'Pressing up with shift' do
|
|
57
|
+
it 'should select next day' do
|
|
58
|
+
expect {
|
|
59
|
+
subject.trigger :keydown, keyCode: 38, shiftKey: true
|
|
60
|
+
}.to change { subject.value }.from(Date.today).to(Date.today.prev_month)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
context 'Selecting a date' do
|
|
65
|
+
it 'should set the value' do
|
|
66
|
+
expect {
|
|
67
|
+
subject.find('[date="2015-01-21"]').trigger :click
|
|
68
|
+
}.to change { subject.value }.from(Date.today).to(Date.parse('2015-01-21'))
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe UI::Drag do
|
|
4
|
+
before do
|
|
5
|
+
allow(subject).to receive(:width).and_return 100
|
|
6
|
+
allow(subject).to receive(:height).and_return 100
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
context 'Dragging on the component' do
|
|
10
|
+
let(:expectation) { expect { mock_drag subject.drag, 10, 10 } }
|
|
11
|
+
|
|
12
|
+
it 'should move the handle horizontally' do
|
|
13
|
+
expectation.to change { subject.handle.style.top }.from('').to('10px')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'should move the handle vertically' do
|
|
17
|
+
expectation.to change { subject.handle.style.left }.from('').to('10px')
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe UI::Dropdown do
|
|
4
|
+
describe '#open' do
|
|
5
|
+
it 'should add open class' do
|
|
6
|
+
expect {
|
|
7
|
+
subject.open
|
|
8
|
+
}.to change { subject.has_class(:open) }.from(false).to(true)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'should set vertical attribute' do
|
|
12
|
+
expect {
|
|
13
|
+
subject.open
|
|
14
|
+
}.to change { subject[:vertical] }.from(nil).to(:bottom)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'should set horizontal attribute' do
|
|
18
|
+
expect {
|
|
19
|
+
subject.open
|
|
20
|
+
}.to change { subject[:horizontal] }.from(nil).to(:right)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe '#close' do
|
|
25
|
+
it 'should remove open class' do
|
|
26
|
+
subject.add_class :open
|
|
27
|
+
expect {
|
|
28
|
+
subject.close
|
|
29
|
+
subject.trigger :animationend, animationName: 'ui-dropdown-hide'
|
|
30
|
+
}.to change { subject.has_class(:open) }.from(true).to(false)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe UI::Image do
|
|
4
|
+
it 'should listen on load' do
|
|
5
|
+
expect {
|
|
6
|
+
subject.img.trigger :load
|
|
7
|
+
}.to change { subject.img.has_class(:loaded) }.from(false).to(true)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe '#width=' do
|
|
11
|
+
it 'should set the width of the image' do
|
|
12
|
+
expect {
|
|
13
|
+
subject.width = '100px'
|
|
14
|
+
}.to change { subject.style.width }.from('').to('100px')
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe '#height=' do
|
|
19
|
+
it 'should set the height of the image' do
|
|
20
|
+
expect {
|
|
21
|
+
subject.height = '100px'
|
|
22
|
+
}.to change { subject.style.height }.from('').to('100px')
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe '#src=' do
|
|
27
|
+
it 'should set the src of the image' do
|
|
28
|
+
expect {
|
|
29
|
+
subject.src = '//placehold.it/250/f9f9f9/333'
|
|
30
|
+
}.to change { subject.src }.from(nil).to('//placehold.it/250/f9f9f9/333')
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|