Sha256: 104db3b7437a6f61b37426d6aa35ce634ff6bb3c286c900a0052ee2d6815b73b

Contents?: true

Size: 1.62 KB

Versions: 14

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

14 entries across 14 versions & 1 rubygems

Version Path
webgen-1.7.2 test/webgen/tag/test_tikz.rb
webgen-1.7.1 test/webgen/tag/test_tikz.rb
webgen-1.7.0 test/webgen/tag/test_tikz.rb
webgen-1.6.0 test/webgen/tag/test_tikz.rb
webgen-1.5.2 test/webgen/tag/test_tikz.rb
webgen-1.5.1 test/webgen/tag/test_tikz.rb
webgen-1.5.0 test/webgen/tag/test_tikz.rb
webgen-1.4.1 test/webgen/tag/test_tikz.rb
webgen-1.4.0 test/webgen/tag/test_tikz.rb
webgen-1.3.0 test/webgen/tag/test_tikz.rb
webgen-1.2.1 test/webgen/tag/test_tikz.rb
webgen-1.2.0 test/webgen/tag/test_tikz.rb
webgen-1.1.0 test/webgen/tag/test_tikz.rb
webgen-1.0.0 test/webgen/tag/test_tikz.rb