Commit fb28ec80 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Detect properties assigned Ext.emptyFn as methods.

parent b4e97120
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -235,7 +235,7 @@ module JsDuck
        when "inheritableStatics"
          cls[:statics] += make_statics(value, {:inheritable => true})
        else
          if value["type"] == "FunctionExpression"
          if function?(value)
            m = make_method(key, value)
            cls[:members] << m if apply_autodetected(m, pair)
          else
@@ -291,7 +291,7 @@ module JsDuck
      statics = []

      each_pair_in_object_expression(ast) do |name, value, pair|
        if value["type"] == "FunctionExpression"
        if function?(value)
          s = make_method(name, value)
        else
          s = make_property(name, value)
+17 −0
Original line number Diff line number Diff line
@@ -219,4 +219,21 @@ describe JsDuck::Aggregator do
    end
  end

  describe "property with value Ext.emptyFn inside Ext.define" do
    let(:method) do
      parse(<<-EOS)[0][:members][:method][0]
        /**
         * Some documentation.
         */
        Ext.define("MyClass", {
            foo: Ext.emptyFn
        });
      EOS
    end

    it "detects a method" do
      method[:tagname].should == :method
    end
  end

end
+19 −0
Original line number Diff line number Diff line
@@ -227,4 +227,23 @@ describe JsDuck::Aggregator do
    end
  end

  describe "Ext.define() with property having value Ext.emptyFn in statics:" do
    let(:methods) do
      parse(<<-EOS)[0][:statics][:method]
        /**
         * Some documentation.
         */
        Ext.define("MyClass", {
            statics: {
                bar: Ext.emptyFn
            }
        });
      EOS
    end

    it "detects one static method" do
      methods.length.should == 1
    end
  end

end