Loading spec/aggregator_spec.rb +168 −0 Original line number Diff line number Diff line Loading @@ -343,6 +343,174 @@ describe JsDuck::Aggregator do it_should_behave_like "no parameters" end shared_examples_for "cfg" do it "creates cfg" do @doc[:tagname].should == :cfg end end shared_examples_for "property" do it "creates property" do @doc[:tagname].should == :property end end shared_examples_for "cfg or property" do it "takes documentation from doc-comment" do @doc[:doc].should == "Some documentation." end it "detects name" do @doc[:name].should == "foo" end end shared_examples_for "cfg or property default type" do it "default type is Object" do @doc[:type].should == "Object" end end shared_examples_for "cfg or property String type" do it "detects type" do @doc[:type].should == "String" end end describe "explicit @cfg" do before do @doc = parse(<<-EOS)[0] /** * @cfg {String} foo * Some documentation. */ EOS end it_should_behave_like "cfg" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "explicit @property" do before do @doc = parse(<<-EOS)[0] /** * @property {String} foo * Some documentation. */ EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "implicit @cfg" do before do @doc = parse(<<-EOS)[0] /** * @cfg * Some documentation. */ foo: "asdf" EOS end it_should_behave_like "cfg" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "implicit @property" do before do @doc = parse(<<-EOS)[0] /** * Some documentation. */ foo: "asdf" EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "typeless @cfg" do before do @doc = parse(<<-EOS)[0] /** * @cfg * Some documentation. */ foo: func(), EOS end it_should_behave_like "cfg" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property default type" end describe "typeless @property" do before do @doc = parse(<<-EOS)[0] /** * @property * Some documentation. */ foo: func(), EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property default type" end describe "@property with @type" do before do @doc = parse(<<-EOS)[0] /** * @property foo * @type String * Some documentation. */ EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "@type without @property" do before do @doc = parse(<<-EOS)[0] /** * @type String * Some documentation. */ MY_CONSTANT: true, EOS end it_should_behave_like "property" it_should_behave_like "cfg or property String type" it "detects name" do @doc[:name].should == "MY_CONSTANT" end end describe "@property with 'this' in ident chain" do before do @doc = parse(<<-EOS)[0] /** * @property * Some documentation. */ this.foo = ""; EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "@member" do it "defines the class where item belongs" do Loading test/tc_jsduck.rb +0 −84 Original line number Diff line number Diff line Loading @@ -139,72 +139,6 @@ MyClass = Ext.extend(Ext.util.Observable, { assert_equal("blah", docs[0][:xtype]) end def test_cfg docs = JsDuck.parse(" /** * @cfg * My comment */ foo: true, ") assert_equal(:cfg, docs[0][:tagname]) assert_equal("foo", docs[0][:name]) assert_equal("My comment", docs[0][:doc]) assert_equal("Boolean", docs[0][:type]) end def test_explicit_property docs = JsDuck.parse(" /** * @property {Integer} foo My comment */ ") assert_equal(:property, docs[0][:tagname]) assert_equal("foo", docs[0][:name]) assert_equal("Integer", docs[0][:type]) assert_equal("My comment", docs[0][:doc]) end def test_property_with_type docs = JsDuck.parse(" /** * @property * @type Boolean * My comment */ foo: true, ") assert_equal(:property, docs[0][:tagname]) assert_equal("foo", docs[0][:name]) assert_equal("Boolean", docs[0][:type]) assert_equal("My comment", docs[0][:doc]) end def test_type_implies_property docs = JsDuck.parse(" /** * @type Boolean */ MY_CONSTANT: true, ") assert_equal(:property, docs[0][:tagname]) assert_equal("MY_CONSTANT", docs[0][:name]) assert_equal("Boolean", docs[0][:type]) end def test_property_ident_chain_begins_with_this docs = JsDuck.parse(" /** * If true then lock actions */ this.locked = false; ") assert_equal(:property, docs[0][:tagname]) assert_equal("locked", docs[0][:name]) assert_equal("Boolean", docs[0][:type]) assert_equal("If true then lock actions", docs[0][:doc]) end def test_implicit_property_type comment = " /** Loading @@ -227,24 +161,6 @@ this.locked = false; assert_equal("Function", docs[0][:type]) end def test_default_property_type_is_object docs = JsDuck.parse(" /** * @property foo */ ") assert_equal("Object", docs[0][:type]) end def test_default_cfg_type_is_object docs = JsDuck.parse(" /** * @cfg foo */ ") assert_equal("Object", docs[0][:type]) end def test_visibility_modifiers ["@private", "@hide", "@ignore", "@protected"].each do |tagname| docs = JsDuck.parse("/**\n * #{tagname}\n */"); Loading Loading
spec/aggregator_spec.rb +168 −0 Original line number Diff line number Diff line Loading @@ -343,6 +343,174 @@ describe JsDuck::Aggregator do it_should_behave_like "no parameters" end shared_examples_for "cfg" do it "creates cfg" do @doc[:tagname].should == :cfg end end shared_examples_for "property" do it "creates property" do @doc[:tagname].should == :property end end shared_examples_for "cfg or property" do it "takes documentation from doc-comment" do @doc[:doc].should == "Some documentation." end it "detects name" do @doc[:name].should == "foo" end end shared_examples_for "cfg or property default type" do it "default type is Object" do @doc[:type].should == "Object" end end shared_examples_for "cfg or property String type" do it "detects type" do @doc[:type].should == "String" end end describe "explicit @cfg" do before do @doc = parse(<<-EOS)[0] /** * @cfg {String} foo * Some documentation. */ EOS end it_should_behave_like "cfg" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "explicit @property" do before do @doc = parse(<<-EOS)[0] /** * @property {String} foo * Some documentation. */ EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "implicit @cfg" do before do @doc = parse(<<-EOS)[0] /** * @cfg * Some documentation. */ foo: "asdf" EOS end it_should_behave_like "cfg" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "implicit @property" do before do @doc = parse(<<-EOS)[0] /** * Some documentation. */ foo: "asdf" EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "typeless @cfg" do before do @doc = parse(<<-EOS)[0] /** * @cfg * Some documentation. */ foo: func(), EOS end it_should_behave_like "cfg" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property default type" end describe "typeless @property" do before do @doc = parse(<<-EOS)[0] /** * @property * Some documentation. */ foo: func(), EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property default type" end describe "@property with @type" do before do @doc = parse(<<-EOS)[0] /** * @property foo * @type String * Some documentation. */ EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "@type without @property" do before do @doc = parse(<<-EOS)[0] /** * @type String * Some documentation. */ MY_CONSTANT: true, EOS end it_should_behave_like "property" it_should_behave_like "cfg or property String type" it "detects name" do @doc[:name].should == "MY_CONSTANT" end end describe "@property with 'this' in ident chain" do before do @doc = parse(<<-EOS)[0] /** * @property * Some documentation. */ this.foo = ""; EOS end it_should_behave_like "property" it_should_behave_like "cfg or property" it_should_behave_like "cfg or property String type" end describe "@member" do it "defines the class where item belongs" do Loading
test/tc_jsduck.rb +0 −84 Original line number Diff line number Diff line Loading @@ -139,72 +139,6 @@ MyClass = Ext.extend(Ext.util.Observable, { assert_equal("blah", docs[0][:xtype]) end def test_cfg docs = JsDuck.parse(" /** * @cfg * My comment */ foo: true, ") assert_equal(:cfg, docs[0][:tagname]) assert_equal("foo", docs[0][:name]) assert_equal("My comment", docs[0][:doc]) assert_equal("Boolean", docs[0][:type]) end def test_explicit_property docs = JsDuck.parse(" /** * @property {Integer} foo My comment */ ") assert_equal(:property, docs[0][:tagname]) assert_equal("foo", docs[0][:name]) assert_equal("Integer", docs[0][:type]) assert_equal("My comment", docs[0][:doc]) end def test_property_with_type docs = JsDuck.parse(" /** * @property * @type Boolean * My comment */ foo: true, ") assert_equal(:property, docs[0][:tagname]) assert_equal("foo", docs[0][:name]) assert_equal("Boolean", docs[0][:type]) assert_equal("My comment", docs[0][:doc]) end def test_type_implies_property docs = JsDuck.parse(" /** * @type Boolean */ MY_CONSTANT: true, ") assert_equal(:property, docs[0][:tagname]) assert_equal("MY_CONSTANT", docs[0][:name]) assert_equal("Boolean", docs[0][:type]) end def test_property_ident_chain_begins_with_this docs = JsDuck.parse(" /** * If true then lock actions */ this.locked = false; ") assert_equal(:property, docs[0][:tagname]) assert_equal("locked", docs[0][:name]) assert_equal("Boolean", docs[0][:type]) assert_equal("If true then lock actions", docs[0][:doc]) end def test_implicit_property_type comment = " /** Loading @@ -227,24 +161,6 @@ this.locked = false; assert_equal("Function", docs[0][:type]) end def test_default_property_type_is_object docs = JsDuck.parse(" /** * @property foo */ ") assert_equal("Object", docs[0][:type]) end def test_default_cfg_type_is_object docs = JsDuck.parse(" /** * @cfg foo */ ") assert_equal("Object", docs[0][:type]) end def test_visibility_modifiers ["@private", "@hide", "@ignore", "@protected"].each do |tagname| docs = JsDuck.parse("/**\n * #{tagname}\n */"); Loading