Commit 90ecf7f1 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Add test for --external option.

parent b463c4ca
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -205,6 +205,39 @@ describe JsDuck::Options::Parser do
    end
  end

  describe :external_classes do
    it "contains JavaScript builtins by default" do
      exts = parse().external_classes
      %w(Object String Number Boolean RegExp Function Array Arguments Date).each do |name|
        exts.should include(name)
      end
    end

    it "contains JavaScript builtin error classes by default" do
      exts = parse().external_classes
      exts.should include("Error")
      %w(Eval Range Reference Syntax Type URI).each do |name|
        exts.should include("#{name}Error")
      end
    end

    it "contains the special anything-goes Mixed type" do
      parse().external_classes.should include("Mixed")
    end

    it "can be used multiple times" do
      exts = parse("--external", "MyClass", "--external", "YourClass").external_classes
      exts.should include("MyClass")
      exts.should include("YourClass")
    end

    it "can be used with comma-separated list" do
      exts = parse("--external", "MyClass,YourClass").external_classes
      exts.should include("MyClass")
      exts.should include("YourClass")
    end
  end

  # Turns :attribute_name into "--option-name" or "--no-option-name"
  def opt(attr, negate=false)
    (negate ? "--no-" : "--") + attr.to_s.gsub(/_/, '-')