Sha256: 3115c5ea146890dedb0ce3be1fbd1f4348c20aab7385f878ae0c87b065acff7c

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

# -*- encoding: utf-8 -*-

require 'webgen/test_helper'

class TestTagTikz < Minitest::Test

  include Webgen::TestHelper

  def test_call
    require 'webgen/tag/tikz' rescue skip($!.message)

    setup_context
    @website.ext.path_handler = Minitest::Mock.new

    root = Webgen::Node.new(@website.tree.dummy_root, '/', '/')
    node = Webgen::Node.new(root, 'file.page', '/file.html')
    tikz_node = Webgen::Node.new(root, 'test.png', '/test.png')
    @context[:chain] = [node]

    body = '\tikz \draw (0,0) -- (0,1);'
    @website.ext.path_handler.expect(:create_secondary_nodes, [tikz_node],
                                    [Webgen::Path.new('/test.png'), body, '/file.page'])
    assert_tag_result('<img src="test.png" alt="" />',
                      body, 'test.png', [], '', '72 72', false, {})
    @website.ext.path_handler.verify

    @website.ext.path_handler.expect(:create_secondary_nodes, [tikz_node],
                                    [Webgen::Path.new('/images/test.png'), body, '/file.page'])
    assert_tag_result('<img src="test.png" alt="title" />',
                      body, 'images/test.png', ['arrows'], '->', '72 72', true, {'alt' => 'title'})
    @website.ext.path_handler.verify

  end

  def assert_tag_result(result, body, path, libs, opts, res, trans, imgattr)
    @context[:config] = {'tag.tikz.path' => path, 'content_processor.tikz.libraries' => libs,
      'content_processor.tikz.opts' => opts, 'content_processor.tikz.resolution' => res,
      'content_processor.tikz.transparent' => trans, 'tag.tikz.img_attr' => imgattr}
    assert_equal(result, Webgen::Tag::Tikz.call('tikz', body, @context))
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webgen-1.7.3 test/webgen/tag/test_tikz.rb