Sha256: 3ebffdf939c68d74961f5a533e8743adc2e1cc88dff54d578fdbee873cedf7c0

Contents?: true

Size: 1.84 KB

Versions: 2

Compression:

Stored size: 1.84 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')
    parent = report.start_new_page

    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

2 entries across 2 versions & 1 rubygems

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