| 1 | require "spec_helper" |
| 2 | |
| 3 | describe "grid-shift" do |
| 4 | before(:all) do |
| 5 | ParserSupport.parse_file("mixins/grid-shift") |
| 6 | end |
| 7 | |
| 8 | context "called with default settings" do |
| 9 | it "adds relative positioning without moving the object" do |
| 10 | rule = "left: auto; position: relative;" |
| 11 | |
| 12 | expect(".grid-shift-default").to have_ruleset(rule) |
| 13 | end |
| 14 | |
| 15 | it "moves the object one column to the right" do |
| 16 | rule = "left: calc(8.33333% - 21.66667px + 20px); position: relative;" |
| 17 | |
| 18 | expect(".grid-shift-1-default").to have_ruleset(rule) |
| 19 | end |
| 20 | |
| 21 | it "moves the object six columns to the right" do |
| 22 | rule = "left: calc(50% - 30px + 20px); position: relative;" |
| 23 | |
| 24 | expect(".grid-shift-6-default").to have_ruleset(rule) |
| 25 | end |
| 26 | |
| 27 | it "moves the object six columns to the left" do |
| 28 | rule = "left: calc(-50% - 10px + 20px); position: relative;" |
| 29 | |
| 30 | expect(".grid-shift-neg-6-default").to have_ruleset(rule) |
| 31 | end |
| 32 | end |
| 33 | |
| 34 | context "called with custom settings" do |
| 35 | it "adds relative positioning without moving the object" do |
| 36 | rule = "left: auto; position: relative;" |
| 37 | |
| 38 | expect(".grid-shift-0-six").to have_ruleset(rule) |
| 39 | end |
| 40 | |
| 41 | it "moves the object one column to the right" do |
| 42 | rule = "left: calc(16.66667% - 2.33333rem + 2rem); position: relative;" |
| 43 | |
| 44 | expect(".grid-shift-1-six").to have_ruleset(rule) |
| 45 | end |
| 46 | |
| 47 | it "moves the object three columns to the right" do |
| 48 | rule = "left: calc(50% - 3rem + 2rem); position: relative;" |
| 49 | |
| 50 | expect(".grid-shift-3-six").to have_ruleset(rule) |
| 51 | end |
| 52 | |
| 53 | it "moves the object three columns to the left" do |
| 54 | rule = "left: calc(-50% - 1rem + 2rem); position: relative;" |
| 55 | |
| 56 | expect(".grid-shift-neg-3-six").to have_ruleset(rule) |
| 57 | end |
| 58 | end |
| 59 | end |