Sha256: 9eabc19bc0be7b5370c30d2b37eb9a4fcc42f011ec4537dcff749158a122d358

Contents?: true

Size: 1.81 KB

Versions: 1

Compression:

Stored size: 1.81 KB

Contents

# coding: utf-8

require 'test_helper'

class Thinreports::Core::Shape::Basic::TestInternal < Minitest::Test
  include Thinreports::TestHelper

  # Alias
  Basic = Thinreports::Core::Shape::Basic

  def create_internal(format_config = {})
    report = Thinreports::Report.new layout: data_file('layout_text1')

    Basic::Internal.new report.page, Basic::Format.new(format_config)
  end

  def test_id_should_operate_as_delegator_of_format
    basic = create_internal('id' => 'basic-id')
    assert_same basic.id, basic.format.id
  end

  def test_svg_tag_should_operate_as_delegator_of_format
    basic = create_internal('svg' => {'tag' => 'rect'})
    assert_same basic.svg_tag, basic.format.svg_tag
  end

  def test_type_should_operate_as_delegator_of_format
    basic = create_internal('type' => 's-ellipse')
    assert_same basic.type, basic.format.type
  end

  def test_style_should_return_instance_of_StyleGraphic
    assert_instance_of Thinreports::Core::Shape::Style::Graphic,
                       create_internal.style
  end

  def test_type_of_asker_should_already_return_true_when_the_specified_type_is_basic
    assert_equal create_internal.type_of?(:basic), true
  end

  def test_type_of_asker_should_return_true_when_the_specified_type_equal_self_type_name
    result = []

    result << create_internal('type' => 's-rect').type_of?(:rect)
    result << create_internal('type' => 's-ellipse').type_of?(:ellipse)
    result << create_internal('type' => 's-line').type_of?(:line)
    result << create_internal('type' => 's-image').type_of?(:image)

    assert_equal result.all?, true
  end

  def test_identifier
    basic = create_internal 'id' => 'basic-id'

    assert_equal 'basic-id', basic.identifier

    basic.style.stubs(identifier: 'style-identifier')
    assert_equal basic.identifier, 'basic-idstyle-identifier'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thinreports-0.8.2 test/unit/core/shape/basic/test_internal.rb