| 1 |
require "spec_helper" |
| 2 |
|
| 3 |
describe "position" do |
| 4 |
before(:all) do |
| 5 |
ParserSupport.parse_file("library/position") |
| 6 |
end |
| 7 |
|
| 8 |
context "called with one size" do |
| 9 |
it "applies same width to all sides" do |
| 10 |
ruleset = "position: fixed; " + |
| 11 |
"top: 1em; " + |
| 12 |
"right: 1em; " + |
| 13 |
"bottom: 1em; " + |
| 14 |
"left: 1em;" |
| 15 |
|
| 16 |
expect(".position-all").to have_ruleset(ruleset) |
| 17 |
end |
| 18 |
end |
| 19 |
|
| 20 |
context "called with two sizes" do |
| 21 |
it "applies to alternating sides" do |
| 22 |
ruleset = "position: absolute; " + |
| 23 |
"top: 2px; " + |
| 24 |
"right: 3px; " + |
| 25 |
"bottom: 2px; " + |
| 26 |
"left: 3px;" |
| 27 |
|
| 28 |
expect(".position-alternate").to have_ruleset(ruleset) |
| 29 |
end |
| 30 |
end |
| 31 |
|
| 32 |
context "called with three sizes" do |
| 33 |
it "applies second width to left and right" do |
| 34 |
ruleset = "position: relative; " + |
| 35 |
"top: 4px; " + |
| 36 |
"right: 5px; " + |
| 37 |
"bottom: 6px; " + |
| 38 |
"left: 5px;" |
| 39 |
|
| 40 |
expect(".position-implied-left").to have_ruleset(ruleset) |
| 41 |
end |
| 42 |
end |
| 43 |
|
| 44 |
context "called with four sizes" do |
| 45 |
it "applies different widths to all sides" do |
| 46 |
ruleset = "position: fixed; " + |
| 47 |
"top: 7px; " + |
| 48 |
"right: 8px; " + |
| 49 |
"bottom: 9px; " + |
| 50 |
"left: 10px;" |
| 51 |
|
| 52 |
expect(".position-explicit").to have_ruleset(ruleset) |
| 53 |
end |
| 54 |
end |
| 55 |
|
| 56 |
context "called with null values" do |
| 57 |
it "writes rules for others" do |
| 58 |
ruleset = "position: static; " + |
| 59 |
"top: 11px; " + |
| 60 |
"left: 13px;" |
| 61 |
bad_rule = "position-bottom: null; position-right: null;" |
| 62 |
|
| 63 |
expect(".position-false-third").to have_ruleset(ruleset) |
| 64 |
expect(".position-false-third").to_not have_rule(bad_rule) |
| 65 |
end |
| 66 |
end |
| 67 |
end |