File tree Expand file tree Collapse file tree 2 files changed +25
-11
lines changed
Expand file tree Collapse file tree 2 files changed +25
-11
lines changed Original file line number Diff line number Diff line change @@ -6,9 +6,10 @@ module Structs
66 class Model < DB ::Struct
77 def css_classes
88 size = css . dig "classes" , "size"
9+ density = css . dig "classes" , "density"
910
1011 "screen screen--#{ name } screen--#{ bit_depth } bit screen--#{ orientation } " \
11- "#{ size } screen--1x" . squeeze " "
12+ "#{ size } screen--1x #{ density } " . strip . squeeze " "
1213 end
1314
1415 def orientation = rotation . zero? ? "landscape" : "portrait"
Original file line number Diff line number Diff line change 33require "hanami_helper"
44
55RSpec . describe Terminus ::Structs ::Model do
6- subject :model do
7- Factory . structs [
8- :model ,
6+ subject ( :model ) { Factory . structs [ :model , **attributes ] }
7+
8+ let :attributes do
9+ {
910 name : "test" ,
1011 label : "Test" ,
11- bit_depth : 2 ,
12- css : { "classes" => { "size" => "screen--lg" } }
13- ]
12+ bit_depth : 4 ,
13+ css : { "classes" => { "size" => "screen--lg" , "density" => "screen--density-2x" } }
14+ }
1415 end
1516
1617 describe "#css_classes" do
1718 it "answers classes with full information" do
1819 expect ( model . css_classes ) . to eq (
19- "screen screen--test screen--2bit screen--landscape screen--lg screen--1x"
20+ "screen screen--test screen--4bit screen--landscape screen--lg " \
21+ "screen--1x screen--density-2x"
2022 )
2123 end
2224
23- it "answers classes with missing information" do
24- model = Factory . structs [ :model , name : nil ]
25- expect ( model . css_classes ) . to eq ( "screen screen-- screen--bit screen--landscape screen--1x" )
25+ it "answers classes with missing values" do
26+ attributes . merge! name : nil , bit_depth : nil
27+
28+ expect ( model . css_classes ) . to eq (
29+ "screen screen-- screen--bit screen--landscape screen--lg screen--1x screen--density-2x"
30+ )
31+ end
32+
33+ it "answers classes without model classes" do
34+ attributes [ :css ] . clear
35+
36+ expect ( model . css_classes ) . to eq (
37+ "screen screen--test screen--4bit screen--landscape screen--1x"
38+ )
2639 end
2740 end
2841
You can’t perform that action at this time.
0 commit comments