require 'minitest_helper'
module SlideHero
describe Slide do
describe "initialization" do
it "is initialized with a title" do
slide = Slide.new("Badgers learn knitting")
slide.headline.must_equal "Badgers learn knitting"
end
it "can take an optional side directive" do
slide = Slide.new("Badgers learn knitting", headline_size: :large)
slide.headline_size.must_equal :large
slide = Slide.new("Snacks lead to revolution in food care", headline_size: :medium)
slide.headline_size.must_equal :medium
end
end
describe "compilation" do
it "outputs object to html" do
slide = Slide.new("To Markup!")
assert_dom_match slide.compile, "" +
"
To Markup!
" +
""
end
it "respects headline size" do
slide = Slide.new("To Markup!", headline_size: :medium)
assert_dom_match slide.compile, "" +
"
To Markup!
" +
""
end
it "takes transitions" do
slide = Slide.new("transitions", transition: :zoom) do
end
assert_dom_match slide.compile, '' +
'
transitions
' +
''
end
end
describe "#point syntax" do
it "embeds text in p tags by default" do
slide = Slide.new "Embedding" do
point "I'm embedded!"
end
assert_dom_match slide.compile, "" +
"
Embedding
" +
"
I'm embedded!
" +
""
end
it "embeds raw html" do
slide = Slide.new "Embedding" do
point "I'm embedded!"
end
assert_dom_match slide.compile, "" +
"
Embedding
" +
"
I'm embedded!
" +
""
end
it "embeds multiple points" do
slide = Slide.new "Embedding" do
point "I'm embedded!"
point "Me too!"
end
assert_dom_match slide.compile, "" +
"
Embedding
" +
"
I'm embedded!
" +
"
Me too!
" +
""
end
it "animates points" do
slide = Slide.new "Animation" do
point "I'm animated!", animation: true
end
assert_dom_match slide.compile, ""+
"
Animation
" +
"
I'm animated!
" +
""
end
end
describe "#list" do
it "creates bullets from a block" do
slide = Slide.new "Lists" do
list do
point "Bullet Points"
point "Another Point"
end
end
assert_dom_match slide.compile, "" +
"
Lists
" +
"
" +
"
Bullet Points
" +
"
Another Point
" +
"
" +
""
end
it "creates ordered lists from a block" do
slide = Slide.new "Lists" do
list(:ordered) do
point "Ordered!"
point "Also ordered!"
end
end
assert_dom_match slide.compile, "" +
"
Lists
" +
"" +
"
Ordered!
" +
"
Also ordered!
" +
"" +
""
end
end
describe "#code" do
it "embeds code in a slide" do
slide = Slide.new "Code" do
code(:ruby, File.join(Dir.pwd,"test","fixtures")) do
"testclass.rb"
end
end
assert_dom_match slide.compile, "" +
"
Code
" +
"
class Working
def some_method
\"woot!\"
end
end
"
end
end
describe "#note" do
it "returns a formatted note" do
slide = Slide.new "Note" do
note "Don't forget to bring a towel"
end
assert_dom_match slide.compile, "" +
"
Note
" +
"" +
""
end
end
describe "#image" do
it "returns a formatted Image" do
slide = Slide.new "Image" do
image("cornify.gif", "Unicorn", width: 280, height: 326)
end
slide.compile.must_include %{}
end
end
describe "#media" do
it "returns a formatted media element" do
slide = Slide.new "Video" do
media "video.mp4", type: :video
end
slide.compile.must_include %{}
end
end
end
end