Sha256: a94980dd5e92aa205ae1edf0ba470561832fa4c3240dc95f6a77a26c758c0bd2

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

require 'test/unit'
require 'tsc-ruby'


class TestTypeScriptRuby < Test::Unit::TestCase
  def test_compile_file_in_success
    file = File.expand_path('data/hello.ts', File.dirname(__FILE__))
    subject = TypeScript::Ruby.compile_file(file)

    assert { subject.exit_status == 0 }
    assert { subject.success? }
    assert { subject.js == %Q{console.log("Hello TypeScript");\n} }
    assert { subject.stdout == '' }
    assert { subject.stderr == '' }
  end

  def test_compile_file_in_failure
    file = File.expand_path('data/bad.ts', File.dirname(__FILE__))
    subject = TypeScript::Ruby.compile_file(file)

    assert { subject.exit_status != 0 }
    assert { !subject.success? }
    assert { subject.stdout != '' || subject.stderr != '' }
  end

  def test_compile_file_with_es5
    file = File.expand_path('data/es5.ts', File.dirname(__FILE__))
    subject = TypeScript::Ruby.compile_file(file, '--target', 'ES5')

    assert { subject.success? }
  end

  def test_compile
    subject = TypeScript::Ruby.compile('class T { say() { console.log("Hello, world!") } }')

    assert { subject != '' }
    assert { subject != nil }
  end

  def test_compile_with_es5
    subject = TypeScript::Ruby.compile('class T { get name() { return "foo" } }', '--target', 'ES5')

    assert { subject != '' }
    assert { subject != nil }
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tsc-ruby-0.1.3 test/test_tsc-ruby.rb
tsc-ruby-0.1.1 test/test_tsc-ruby.rb
tsc-ruby-0.1.0 test/test_tsc-ruby.rb