Sha256: fe84433e42b98ab249da633ab1cbfcac32df4f8920bba128f7ebec18cde9bd43

Contents?: true

Size: 1.66 KB

Versions: 3

Compression:

Stored size: 1.66 KB

Contents

# coding: utf-8

require 'test_helper'

class Thinreports::Generator::PDF::TestDrawShape < Minitest::Test
  include Thinreports::TestHelper

  def setup
    @pdf = Thinreports::Generator::PDF::Document.new
  end

  def create_tblock_interface(format_config = {})
    report = new_report 'layout_text1'
    parent = report.start_new_page

    format = Thinreports::Core::Shape::TextBlock::Format.new format_config
    Thinreports::Core::Shape::TextBlock::Interface.new parent, format
  end

  def test_shape_text_attrs_should_return_attrs_containing_an_overflow_property
    tblock = create_tblock_interface('id' => 'text', 'overflow' => 'truncate')
    assert_equal @pdf.send(:shape_text_attrs, tblock.internal)[:overflow], :truncate
  end

  def test_shape_text_attrs_should_return_attrs_containing_an_valign_property
    tblock = create_tblock_interface('id' => 'text', 'valign' => 'top')
    assert_equal @pdf.send(:shape_text_attrs, tblock.internal)[:valign], :top
  end

  def test_shape_text_attrs_should_return_attrs_containing_an_line_height_unless_line_height_is_blank
    tblock = create_tblock_interface('id' => 'text', 'line-height' => '10')
    assert_equal @pdf.send(:shape_text_attrs, tblock.internal)[:line_height], '10'
  end

  def test_shape_text_attrs_should_return_attrs_uncontaining_an_line_height_if_line_height_is_blank
    tblock = create_tblock_interface('id' => 'text', 'line-height' => '')
    assert_nil @pdf.send(:shape_text_attrs, tblock.internal)[:line_height]
  end

  def test_shape_text_attrs
    tblock = create_tblock_interface('id' => 'text', 'word-wrap' => 'none')
    assert_includes @pdf.send(:shape_text_attrs, tblock.internal).keys, :word_wrap
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thinreports-0.8.2 test/unit/generator/pdf/document/test_draw_shape.rb
thinreports-0.8.1 test/unit/generator/pdf/document/test_draw_shape.rb
thinreports-0.8.0 test/unit/generator/pdf/document/test_draw_shape.rb