Sha256: 9bda7fee816621697455e416017829efdc9dfcfbc72b7947552acdf0f162bb2f

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

gem "minitest"
require 'minitest/spec'
require "minitest/autorun"
require "svelte"

class TestSvelte < Minitest::Test
  def setup
    @files                    = File.join(File.expand_path(File.dirname(__FILE__)), "files")
    @hello_world_filename     = File.join(@files, 'hello_world.html')
    @hello_world_output       = IO.read(File.join(@files, 'hello_world_output.txt'))
    @hello_world_output_iife  = IO.read(File.join(@files, 'hello_world_output_iife.txt'))
  end

  def test_version
    exp = "1.12.1"
    act = Svelte.exec_eval('svelte.VERSION')
    assert_equal exp, act
  end

  def test_compile_with_string
    exp = @hello_world_output
    act = Svelte.exec_method('svelte.compile', '<h1>Hello {{name}}</h1>')
    assert_kind_of Hash, act
    assert_equal exp, act['code']
  end

  def test_compile_with_file
    exp = @hello_world_output
    act = Svelte.exec_method('svelte.compile', @hello_world_filename)
    assert_kind_of Hash, act
    assert_equal exp, act['code']
  end

  def test_compile_with_file_and_args_iife
    exp = @hello_world_output_iife
    act = Svelte.exec_method('svelte.compile', @hello_world_filename, nil, format: 'iife', name: 'SvelteComponent')

    # generate test output
    #IO.write(File.join(@files,'hello_world_output_iife.txt'), act['code'])

    assert_kind_of Hash, act
    assert_equal exp, act['code']
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
svelte-ruby-0.1.0 test/test_svelte.rb