lends.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. 'use strict';
  2. describe('lends', function() {
  3. describe('when a documented member is inside an object literal associated with a @lends tag', function() {
  4. function removeUndocumented($) {
  5. return !($.undocumented);
  6. }
  7. describe('standard case', function() {
  8. var docSet = jasmine.getDocSetFromFile('test/fixtures/lends.js');
  9. var init = docSet.getByLongname('Person#initialize');
  10. var name = docSet.getByLongname('Person#name');
  11. it('The member should be documented as a member of the lendee', function() {
  12. expect(init.length, 1);
  13. });
  14. it('The this member should be documented as a member of the lendee', function() {
  15. expect(name.length, 1);
  16. });
  17. });
  18. describe('case containing constructor', function() {
  19. var docSet = jasmine.getDocSetFromFile('test/fixtures/lends2.js');
  20. var person = docSet.getByLongname('Person').filter(removeUndocumented)[0];
  21. var name = docSet.getByLongname('Person#name');
  22. it('A tag with a @constructs tag is documented as a constructor.', function() {
  23. expect(person.description).toBe('Construct a Person.');
  24. });
  25. it('The member should be documented as a member of the lendee', function() {
  26. expect(person.length, 1);
  27. });
  28. it('The this member should be documented as a member of the lendee', function() {
  29. expect(name.length, 1);
  30. });
  31. });
  32. describe('case that uses @lends in a multiline doclet', function() {
  33. var docSet = jasmine.getDocSetFromFile('test/fixtures/lends3.js');
  34. var init = docSet.getByLongname('Person#initialize');
  35. var name = docSet.getByLongname('Person#name');
  36. it('The member should be documented as a member of the lendee', function() {
  37. expect(init.length, 1);
  38. });
  39. it('The this member should be documented as a member of the lendee', function() {
  40. expect(name.length, 1);
  41. });
  42. });
  43. describe('case that uses @lends within a closure', function() {
  44. var docSet = jasmine.getDocSetFromFile('test/fixtures/lends4.js');
  45. var person = docSet.getByLongname('Person');
  46. var say = docSet.getByLongname('Person#say');
  47. it('The class constructor should be documented with the name of the lendee', function() {
  48. expect(person.length).toBe(1);
  49. expect(person[0].name).toBe('Person');
  50. expect(person[0].kind).toBe('class');
  51. });
  52. it('A class\' instance method should be documented as a member of the lendee', function() {
  53. expect(say.length).toBe(1);
  54. });
  55. });
  56. describe('case that uses @lends within nested function calls', function() {
  57. var docSet = jasmine.getDocSetFromFile('test/fixtures/lends5.js');
  58. var person = docSet.getByLongname('Person').filter(removeUndocumented)[0];
  59. var say = docSet.getByLongname('Person#say').filter(removeUndocumented)[0];
  60. it('The class constructor should be documented with the name of the lendee', function() {
  61. expect(person).toBeDefined();
  62. expect(person.name).toBe('Person');
  63. expect(person.kind).toBe('class');
  64. });
  65. it('A class\' instance method should be documented as a member of the lendee', function() {
  66. expect(say).toBeDefined();
  67. });
  68. });
  69. describe('case that uses @lends twice within a closure', function() {
  70. var docSet = jasmine.getDocSetFromFile('test/fixtures/lends6.js');
  71. it('The first class with a @lends tag should appear in the parse results', function() {
  72. var person = docSet.getByLongname('Person').filter(removeUndocumented)[0];
  73. var say = docSet.getByLongname('Person#say').filter(removeUndocumented)[0];
  74. expect(person).toBeDefined();
  75. expect(person.name).toBe('Person');
  76. expect(person.kind).toBe('class');
  77. expect(say).toBeDefined();
  78. expect(say.name).toBe('say');
  79. expect(say.kind).toBe('function');
  80. });
  81. it('The second class with a @lends tag should appear in the parse results', function() {
  82. var robot = docSet.getByLongname('Robot').filter(removeUndocumented)[0];
  83. var emote = docSet.getByLongname('Robot#emote').filter(removeUndocumented)[0];
  84. expect(robot).toBeDefined();
  85. expect(robot.name).toBe('Robot');
  86. expect(robot.kind).toBe('class');
  87. expect(emote).toBeDefined();
  88. expect(emote.name).toBe('emote');
  89. expect(emote.kind).toBe('function');
  90. });
  91. });
  92. });
  93. describe('when a documented member is inside an objlit associated with a @lends tag that has no value.', function() {
  94. var docSet = jasmine.getDocSetFromFile('test/fixtures/lendsglobal.js');
  95. var testf = docSet.getByLongname('test')[0];
  96. var test12 = docSet.getByLongname('test1.test2')[0];
  97. it('The members of the objlit are not members of any symbol', function() {
  98. expect(typeof testf.memberof).toBe('undefined');
  99. });
  100. it('The members of the objlit are documented as global.', function() {
  101. expect(testf.longname).toBe('test');
  102. });
  103. it('The nested members of the objlit are members of a global symbol', function() {
  104. expect(test12.memberof).toBe('test1');
  105. });
  106. });
  107. });