Sha256: acb4c4dd30a1223ef6e9a0f36ca4b544eb1f28195a1ac2bcbb8b8e5bc5126315

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

# coding: utf-8

require 'test_helper'

class Thinreports::Core::Shape::PageNumber::TestFormat < Minitest::Test
  include Thinreports::TestHelper

  TEST_PAGENO_FORMAT = {
    "type" => "s-pageno", 
    "id" => "", 
    "display" => "true", 
    "box" => {
      "x" => 100.0, 
      "y" => 100.0, 
      "width" => 100.0, 
      "height" => 100.0
    },
    "format" => "{page} / {total}",
    "overflow" => "truncate", 
    "target" => "",
    "svg" => {
      "tag" => "text",
      "attrs" => {
        "x" => 308.2,
        "y" => 239,
        "kerning" => "auto",
        "id" => "goog_939685354",
        "fill" => "#000000",
        "fill-opacity" => "1",
        "font-size" => "18",
        "font-family" => "Helvetica",
        "font-weight" => "normal",
        "font-style" => "normal",
        "text-anchor" => "middle",
        "text-decoration" => "none"
      }
    }
  }

  Format = Thinreports::Core::Shape::PageNumber::Format

  def format(raw_format = nil)
    Format.new(raw_format || TEST_PAGENO_FORMAT)
  end

  def test_build
    Format.build(TEST_PAGENO_FORMAT)
  rescue => e
    flunk exception_details(e, 'Failed to build')
  end

  def test_id
    pageno = format('id' => 'pageno_id')
    assert_equal pageno.id, 'pageno_id'

    pageno = format('id' => '')
    assert_equal pageno.id, '__pageno1'
    assert_same pageno.id, pageno.id
  end

  def test_overflow
    assert_equal format.overflow, 'truncate'
  end

  def test_target
    assert_equal format.target, ''
    assert_equal format("target" => "list-id").target, 'list-id'
  end

  def test_default_format
    assert_equal format.default_format, '{page} / {total}'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thinreports-0.8.2 test/unit/core/shape/page_number/test_format.rb
thinreports-0.8.1 test/unit/core/shape/page_number/test_format.rb
thinreports-0.8.0 test/unit/core/shape/page_number/test_format.rb