under-os-ui 1.4.0
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/README.md +26 -0
- data/lib/assets/fontawesome-webfont.ttf +0 -0
- data/lib/assets/under-os.css +115 -0
- data/lib/core/kernel.rb +16 -0
- data/lib/under-os-ui.rb +6 -0
- data/lib/under_os/app.rb +26 -0
- data/lib/under_os/config.rb +25 -0
- data/lib/under_os/history.rb +53 -0
- data/lib/under_os/page.rb +178 -0
- data/lib/under_os/page/builder.rb +96 -0
- data/lib/under_os/page/layout.rb +43 -0
- data/lib/under_os/page/matcher.rb +128 -0
- data/lib/under_os/page/stylesheet.rb +67 -0
- data/lib/under_os/parser.rb +24 -0
- data/lib/under_os/parser/css.rb +37 -0
- data/lib/under_os/parser/html.rb +97 -0
- data/lib/under_os/ui.rb +3 -0
- data/lib/under_os/ui/alert.rb +52 -0
- data/lib/under_os/ui/button.rb +42 -0
- data/lib/under_os/ui/collection.rb +65 -0
- data/lib/under_os/ui/collection/cell.rb +21 -0
- data/lib/under_os/ui/collection/delegate.rb +70 -0
- data/lib/under_os/ui/collection/item.rb +32 -0
- data/lib/under_os/ui/collection/layout.rb +43 -0
- data/lib/under_os/ui/collection/styles.rb +15 -0
- data/lib/under_os/ui/div.rb +3 -0
- data/lib/under_os/ui/form.rb +60 -0
- data/lib/under_os/ui/icon.rb +61 -0
- data/lib/under_os/ui/icon/awesome.rb +376 -0
- data/lib/under_os/ui/icon/engine.rb +9 -0
- data/lib/under_os/ui/image.rb +31 -0
- data/lib/under_os/ui/input.rb +140 -0
- data/lib/under_os/ui/label.rb +21 -0
- data/lib/under_os/ui/locker.rb +42 -0
- data/lib/under_os/ui/navbar.rb +123 -0
- data/lib/under_os/ui/progress.rb +17 -0
- data/lib/under_os/ui/scroll.rb +102 -0
- data/lib/under_os/ui/select.rb +95 -0
- data/lib/under_os/ui/sidebar.rb +45 -0
- data/lib/under_os/ui/slider.rb +37 -0
- data/lib/under_os/ui/spinner.rb +23 -0
- data/lib/under_os/ui/style.rb +21 -0
- data/lib/under_os/ui/style/fonts.rb +56 -0
- data/lib/under_os/ui/style/margins.rb +164 -0
- data/lib/under_os/ui/style/outlining.rb +170 -0
- data/lib/under_os/ui/style/positioning.rb +183 -0
- data/lib/under_os/ui/switch.rb +26 -0
- data/lib/under_os/ui/textarea.rb +19 -0
- data/lib/under_os/ui/utils/animation.rb +101 -0
- data/lib/under_os/ui/utils/commons.rb +70 -0
- data/lib/under_os/ui/utils/dimensions.rb +37 -0
- data/lib/under_os/ui/utils/events.rb +210 -0
- data/lib/under_os/ui/utils/manipulation.rb +44 -0
- data/lib/under_os/ui/utils/position.rb +21 -0
- data/lib/under_os/ui/utils/size.rb +21 -0
- data/lib/under_os/ui/utils/styles.rb +89 -0
- data/lib/under_os/ui/utils/traversing.rb +44 -0
- data/lib/under_os/ui/utils/wrap.rb +77 -0
- data/lib/under_os/ui/view.rb +31 -0
- data/spec/assets/app.css +13 -0
- data/spec/assets/test.css +7 -0
- data/spec/assets/test.html +3 -0
- data/spec/assets/test.png +0 -0
- data/spec/assets/test_page.rb +2 -0
- data/spec/under_os/page/builder_spec.rb +128 -0
- data/spec/under_os/page/layout_spec.rb +18 -0
- data/spec/under_os/page/matcher_spec.rb +260 -0
- data/spec/under_os/page/stylesheet_spec.rb +83 -0
- data/spec/under_os/page_spec.rb +5 -0
- data/spec/under_os/parser/css_spec.rb +77 -0
- data/spec/under_os/parser/html_spec.rb +152 -0
- data/spec/under_os/parser_spec.rb +16 -0
- data/spec/under_os/ui/button_spec.rb +50 -0
- data/spec/under_os/ui/collection_spec.rb +19 -0
- data/spec/under_os/ui/div_spec.rb +24 -0
- data/spec/under_os/ui/form_spec.rb +156 -0
- data/spec/under_os/ui/icon_spec.rb +57 -0
- data/spec/under_os/ui/image_spec.rb +39 -0
- data/spec/under_os/ui/input_spec.rb +109 -0
- data/spec/under_os/ui/label_spec.rb +22 -0
- data/spec/under_os/ui/locker_spec.rb +31 -0
- data/spec/under_os/ui/progress_spec.rb +31 -0
- data/spec/under_os/ui/scroll_spec.rb +75 -0
- data/spec/under_os/ui/select_spec.rb +135 -0
- data/spec/under_os/ui/sidebar_spec.rb +35 -0
- data/spec/under_os/ui/slider_spec.rb +69 -0
- data/spec/under_os/ui/spinner_spec.rb +57 -0
- data/spec/under_os/ui/style/fonts_spec.rb +111 -0
- data/spec/under_os/ui/style/margins_spec.rb +106 -0
- data/spec/under_os/ui/style/outlining_spec.rb +101 -0
- data/spec/under_os/ui/style/positioning_spec.rb +69 -0
- data/spec/under_os/ui/style_spec.rb +19 -0
- data/spec/under_os/ui/switch_spec.rb +60 -0
- data/spec/under_os/ui/textarea_spec.rb +34 -0
- data/spec/under_os/ui/utils/commons_spec.rb +81 -0
- data/spec/under_os/ui/utils/events_spec.rb +87 -0
- data/spec/under_os/ui/utils/manipulation_spec.rb +130 -0
- data/spec/under_os/ui/utils/styles_spec.rb +140 -0
- data/spec/under_os/ui/utils/traversing_spec.rb +124 -0
- data/spec/under_os/ui/utils/wrap_spec.rb +69 -0
- data/spec/under_os/ui/view_spec.rb +39 -0
- data/under-os-ui.gemspec +23 -0
- metadata +216 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
describe UnderOs::UI::Style::Fonts do
|
|
2
|
+
before do
|
|
3
|
+
@view = UnderOs::UI::View.new
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
describe 'fontFamily' do
|
|
7
|
+
before { @view = UnderOs::UI::Label.new(text: "Hello")}
|
|
8
|
+
|
|
9
|
+
it "should return the view's font family name" do
|
|
10
|
+
@view.style.fontFamily.should == @view._.font.familyName
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "allows to set a new family name" do
|
|
14
|
+
@view.style.fontFamily = "Chalkduster"
|
|
15
|
+
@view._.font.familyName.should == "Chalkduster"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should keep the original font-size" do
|
|
19
|
+
@view.style.fontSize = 20
|
|
20
|
+
@view.style.fontFamily = "Chalkduster"
|
|
21
|
+
@view._.font.pointSize.should == 20.0
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe "fontSize" do
|
|
26
|
+
before { @view = UnderOs::UI::Label.new(text: "Hello")}
|
|
27
|
+
|
|
28
|
+
it "returns the labels current font-size" do
|
|
29
|
+
@view.style.fontSize.should == @view._.font.pointSize
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "allows to the new font size" do
|
|
33
|
+
@view.style.fontSize = 40
|
|
34
|
+
@view._.font.pointSize.should == 40.0
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "keeps the original font family" do
|
|
38
|
+
@view.style.fontFamily = "Chalkduster"
|
|
39
|
+
@view.style.fontSize = 30
|
|
40
|
+
@view._.font.familyName.should == "Chalkduster"
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe 'text-align' do
|
|
45
|
+
|
|
46
|
+
it "should not crash when called on unsupported elements" do
|
|
47
|
+
@view.style.textAlign = 'left'
|
|
48
|
+
true.should == true
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe 'with a label' do
|
|
52
|
+
before do
|
|
53
|
+
@view = UnderOs::UI::Label.new(text: "Hello")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "should allow to align the text to the left" do
|
|
57
|
+
@view.style.textAlign = 'left'
|
|
58
|
+
@view._.textAlignment.should == NSTextAlignmentLeft
|
|
59
|
+
@view.style.textAlign.should == 'left'
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should allow to align the text to the right" do
|
|
63
|
+
@view.style.textAlign = 'right'
|
|
64
|
+
@view._.textAlignment.should == NSTextAlignmentRight
|
|
65
|
+
@view.style.textAlign.should == 'right'
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "should allow to align the text to the center" do
|
|
69
|
+
@view.style.textAlign = 'center'
|
|
70
|
+
@view._.textAlignment.should == NSTextAlignmentCenter
|
|
71
|
+
@view.style.textAlign.should == 'center'
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# it "should allow to align the text to fill the size" do
|
|
75
|
+
# @view.style.textAlign = 'justify'
|
|
76
|
+
# @view._.textAlignment.should == NSTextAlignmentJustified
|
|
77
|
+
# @view.style.textAlign.should == 'justify'
|
|
78
|
+
# end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
describe 'with a button' do
|
|
82
|
+
before do
|
|
83
|
+
@view = UnderOs::UI::Button.new(text: "Hello")
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "should allow to align the text to the left" do
|
|
87
|
+
@view.style.textAlign = 'left'
|
|
88
|
+
@view._.contentHorizontalAlignment.should == UIControlContentHorizontalAlignmentLeft
|
|
89
|
+
@view.style.textAlign.should == 'left'
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "should allow to align the text to the right" do
|
|
93
|
+
@view.style.textAlign = 'right'
|
|
94
|
+
@view._.contentHorizontalAlignment.should == UIControlContentHorizontalAlignmentRight
|
|
95
|
+
@view.style.textAlign.should == 'right'
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it "should allow to align the text to the center" do
|
|
99
|
+
@view.style.textAlign = 'center'
|
|
100
|
+
@view._.contentHorizontalAlignment.should == UIControlContentHorizontalAlignmentCenter
|
|
101
|
+
@view.style.textAlign.should == 'center'
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it "should allow to align the text to fill the size" do
|
|
105
|
+
@view.style.textAlign = 'justify'
|
|
106
|
+
@view._.contentHorizontalAlignment.should == UIControlContentHorizontalAlignmentFill
|
|
107
|
+
@view.style.textAlign.should == 'justify'
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
describe UnderOs::UI::Style::Margins do
|
|
2
|
+
before do
|
|
3
|
+
@view = UnderOs::UI::View.new
|
|
4
|
+
@style = @view.style
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
describe '#display' do
|
|
8
|
+
it "should return :block by default" do
|
|
9
|
+
@view.style.display.should == :block
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should understand the 'none' value" do
|
|
13
|
+
@view.style.display = 'none'
|
|
14
|
+
@view.hidden.should == true
|
|
15
|
+
@view.style.display.should == :none
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should understand the 'block' value" do
|
|
19
|
+
@view.style.display = 'block'
|
|
20
|
+
@view.visible.should == true
|
|
21
|
+
@view.style.display.should == :block
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe '#margin' do
|
|
26
|
+
it "should return an array of zeros by default" do
|
|
27
|
+
@style.margin.should == [0, 0, 0, 0]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'should accept simple numbers' do
|
|
31
|
+
@style.margin = 10
|
|
32
|
+
@style.margin.should == [10, 10, 10, 10]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should accept arrays" do
|
|
36
|
+
@style.margin = [20]
|
|
37
|
+
@style.margin.should == [20, 20, 20, 20]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should accept two dim arrays" do
|
|
41
|
+
@style.margin = [10, 20]
|
|
42
|
+
@style.margin.should == [10, 20, 10, 20]
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "should accept four dims arrays" do
|
|
46
|
+
@style.margin = [10, 20, 30, 40]
|
|
47
|
+
@style.margin.should == [10, 20, 30, 40]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should accept single value strings" do
|
|
51
|
+
@style.margin = '10px'
|
|
52
|
+
@style.margin.should == [10, 10, 10, 10]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should accept two value strings" do
|
|
56
|
+
@style.margin = '10px 20'
|
|
57
|
+
@style.margin.should == [10, 20, 10, 20]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "should accept the four values strings" do
|
|
61
|
+
@style.margin = '10px 20 30px 40'
|
|
62
|
+
@style.margin.should == [10, 20, 30, 40]
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe '#padding' do
|
|
67
|
+
it "should return an array of zeros by default" do
|
|
68
|
+
@style.padding.should == [0, 0, 0, 0]
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'should accept simple numbers' do
|
|
72
|
+
@style.padding = 10
|
|
73
|
+
@style.padding.should == [10, 10, 10, 10]
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "should accept arrays" do
|
|
77
|
+
@style.padding = [20]
|
|
78
|
+
@style.padding.should == [20, 20, 20, 20]
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "should accept two dim arrays" do
|
|
82
|
+
@style.padding = [10, 20]
|
|
83
|
+
@style.padding.should == [10, 20, 10, 20]
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "should accept four dims arrays" do
|
|
87
|
+
@style.padding = [10, 20, 30, 40]
|
|
88
|
+
@style.padding.should == [10, 20, 30, 40]
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "should accept single value strings" do
|
|
92
|
+
@style.padding = '10px'
|
|
93
|
+
@style.padding.should == [10, 10, 10, 10]
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it "should accept two value strings" do
|
|
97
|
+
@style.padding = '10px 20'
|
|
98
|
+
@style.padding.should == [10, 20, 10, 20]
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "should accept the four values strings" do
|
|
102
|
+
@style.padding = '10px 20 30px 40'
|
|
103
|
+
@style.padding.should == [10, 20, 30, 40]
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
describe UnderOs::UI::Style::Outlining do
|
|
2
|
+
before do
|
|
3
|
+
@view = UnderOs::UI::View.new
|
|
4
|
+
@style = @view.style
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
describe '#borderRadius' do
|
|
8
|
+
it "should allow to set it" do
|
|
9
|
+
@style.borderRadius = 10
|
|
10
|
+
@style.borderRadius.should == 10
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should change the view's layout property" do
|
|
14
|
+
@style.borderRadius = 20
|
|
15
|
+
@view._.clipsToBounds.should == true
|
|
16
|
+
@view._.layer.cornerRadius.should == 20
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe '#color' do
|
|
21
|
+
describe 'buttons' do
|
|
22
|
+
before do
|
|
23
|
+
@button = UnderOs::UI::Button.new
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should allow to set the colors" do
|
|
27
|
+
@button.style.color = UIColor.redColor
|
|
28
|
+
@button._.titleColorForState(UIControlStateNormal).should == UIColor.redColor
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should return the curent button color" do
|
|
32
|
+
@button.style.color = UIColor.yellowColor
|
|
33
|
+
@button.style.color.should == UIColor.yellowColor
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe 'label' do
|
|
38
|
+
before do
|
|
39
|
+
@label = UnderOs::UI::Label.new
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should change the text color" do
|
|
43
|
+
@label.style.color = UIColor.redColor
|
|
44
|
+
@label._.textColor.should == UIColor.redColor
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should return the current text color" do
|
|
48
|
+
@label.style.color = UIColor.yellowColor
|
|
49
|
+
@label.style.color.should == UIColor.yellowColor
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe 'spinner' do
|
|
54
|
+
before do
|
|
55
|
+
@spinner = UnderOs::UI::Spinner.new
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should change the color of the spinner" do
|
|
59
|
+
@spinner.style.color = UIColor.redColor
|
|
60
|
+
@spinner._.color.should == UIColor.redColor
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "should return the current spinner color" do
|
|
64
|
+
@spinner.style.color = UIColor.yellowColor
|
|
65
|
+
@spinner.style.color.should == UIColor.yellowColor
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe '#boxShadow' do
|
|
71
|
+
it "recognizes the x, y values" do
|
|
72
|
+
@view.style.boxShadow = "1px 2px"
|
|
73
|
+
@view.style.boxShadow.should == "1.0 2.0 3.0 0.0 #ff0000"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "recognizes the x, y, radius values" do
|
|
77
|
+
@view.style.boxShadow = "-1 -2 4"
|
|
78
|
+
@view.style.boxShadow.should == "-1.0 -2.0 4.0 0.0 #ff0000"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "recognizes the x, y, radius, opacity values" do
|
|
82
|
+
@view.style.boxShadow = "4 5 6 7"
|
|
83
|
+
@view.style.boxShadow.should == "4.0 5.0 6.0 7.0 #ff0000"
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "recognizes the x, y, radius, opacity, color values" do
|
|
87
|
+
@view.style.boxShadow = "4 5 6 7 blue"
|
|
88
|
+
@view.style.boxShadow.should == "4.0 5.0 6.0 7.0 #ff0000"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "recognizes the x, y, radius, color values" do
|
|
92
|
+
@view.style.boxShadow = "4 5 6 blue"
|
|
93
|
+
@view.style.boxShadow.should == "4.0 5.0 6.0 0.0 #ff0000"
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it "recognizes the x, y, color values" do
|
|
97
|
+
@view.style.boxShadow = "4 5 green"
|
|
98
|
+
@view.style.boxShadow.should == "4.0 5.0 3.0 0.0 #ff0000"
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
describe UnderOs::UI::Style::Positioning do
|
|
2
|
+
before do
|
|
3
|
+
@view = UnderOs::UI::View.new
|
|
4
|
+
@style = @view.style
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
describe '#contentWidth' do
|
|
8
|
+
before do
|
|
9
|
+
@view = UnderOs::UI::Scroll.new
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should allow to set the content sizes" do
|
|
13
|
+
@view.style.contentWidth = 100
|
|
14
|
+
@view.style.contentHeight = 200
|
|
15
|
+
|
|
16
|
+
@view.style.contentWidth.should == 100
|
|
17
|
+
@view.style.contentHeight.should == 200
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe '#zIndex' do
|
|
22
|
+
it "should return 0 by default" do
|
|
23
|
+
@view.style.zIndex.should == 0
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should allow to change it" do
|
|
27
|
+
@view.style.zIndex = 100
|
|
28
|
+
@view.style.zIndex.should == 100
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe 'scroller related styles' do
|
|
33
|
+
before do
|
|
34
|
+
@view = UnderOs::UI::Scroll.new
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe '#overflow' do
|
|
38
|
+
it "accepts 'hidden'" do
|
|
39
|
+
@view.style.overflow = :hidden
|
|
40
|
+
@view.style.overflowX.should == :hidden
|
|
41
|
+
@view.style.overflowY.should == :hidden
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "accepts 'scroll'" do
|
|
45
|
+
@view.style.overflow = :scroll
|
|
46
|
+
@view.style.overflowX.should == :scroll
|
|
47
|
+
@view.style.overflowY.should == :scroll
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "accepts 'x'" do
|
|
51
|
+
@view.style.overflow = 'x'
|
|
52
|
+
@view.style.overflowX.should == :scroll
|
|
53
|
+
@view.style.overflowY.should == :hidden
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "accepts 'y'" do
|
|
57
|
+
@view.style.overflow = 'y'
|
|
58
|
+
@view.style.overflowX.should == :hidden
|
|
59
|
+
@view.style.overflowY.should == :scroll
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "falls back to 'visible'" do
|
|
63
|
+
@view.style.overflow = 'weird stuff'
|
|
64
|
+
@view.style.overflowX.should == :scroll
|
|
65
|
+
@view.style.overflowY.should == :scroll
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
describe UnderOs::UI::Style do
|
|
2
|
+
before do
|
|
3
|
+
@view = UnderOs::UI::View.new
|
|
4
|
+
@style = @view.style
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
it "should be an instance of UnderOs::UI::Style" do
|
|
8
|
+
@style.class.should == UnderOs::UI::Style
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should incapsulate the Element's raw uiview object" do
|
|
12
|
+
@style.view.should === @view._
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should always return the same object" do
|
|
16
|
+
@view.style.should === @style
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
describe UnderOs::UI::Switch do
|
|
2
|
+
before do
|
|
3
|
+
@switch = UnderOs::UI::Switch.new
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
it "inherits fromthe UnderOs::UI::Input" do
|
|
7
|
+
(UnderOs::UI::Switch < UnderOs::UI::Input).should == true
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe '#initialize' do
|
|
11
|
+
it "should spawn new switchs" do
|
|
12
|
+
@switch.class.should == UnderOs::UI::Switch
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should wrap the UISwitch class" do
|
|
16
|
+
@switch._.class.should == UISwitch
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should assign correct tag name" do
|
|
20
|
+
@switch.tagName.should == 'SWITCH'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should accept the 'value' option" do
|
|
24
|
+
switch = UnderOs::UI::Switch.new(value: 'smth')
|
|
25
|
+
switch.value.should == 'smth'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should accept the 'checked' option" do
|
|
29
|
+
switch = UnderOs::UI::Switch.new(checked: true)
|
|
30
|
+
switch.checked.should == true
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe '#value' do
|
|
35
|
+
it "should save the value correctly" do
|
|
36
|
+
@switch.value = 'something'
|
|
37
|
+
@switch.value.should == 'something'
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe '#checked' do
|
|
42
|
+
it "should allow to flip the switch on" do
|
|
43
|
+
@switch.checked = true
|
|
44
|
+
@switch._.on?.should == true
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should allow to flip the switch off" do
|
|
48
|
+
@switch.checked = false
|
|
49
|
+
@switch._.on?.should == false
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "should return the state back correctly" do
|
|
53
|
+
@switch.checked = true
|
|
54
|
+
@switch.checked.should == true
|
|
55
|
+
|
|
56
|
+
@switch.checked = false
|
|
57
|
+
@switch.checked.should == false
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|