also.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. 'use strict';
  2. var env = require('jsdoc/env');
  3. describe('multiple doclets per symbol', function() {
  4. function undocumented($) {
  5. return !($.undocumented);
  6. }
  7. function checkInequality(doclets, property) {
  8. for (var l = doclets.length - 1; l > 0; l--) {
  9. if (doclets[l][property] !== undefined && doclets[l - 1][property] !== undefined) {
  10. expect(doclets[l][property]).not.toBe(doclets[l - 1][property]);
  11. }
  12. }
  13. }
  14. var docSet = jasmine.getDocSetFromFile('test/fixtures/also.js');
  15. var name = docSet.getByLongname('Asset#name').filter(undocumented);
  16. var shape = docSet.getByLongname('Asset#shape').filter(undocumented);
  17. it('When a symbol has multiple adjacent JSDoc comments, both apply to the symbol.', function() {
  18. expect(name.length).toBe(2);
  19. expect(shape.length).toBe(3);
  20. });
  21. it('When a symbol has multiple adjacent JSDoc comments that are not identical, the doclets ' +
  22. 'have different comments.', function() {
  23. checkInequality(name, 'comment');
  24. checkInequality(shape, 'comment');
  25. });
  26. it('When a symbol has multiple adjacent JSDoc comments with different descriptions, ' +
  27. 'the doclets have different descriptions.', function() {
  28. checkInequality(name, 'description');
  29. checkInequality(shape, 'description');
  30. });
  31. it('When a symbol has multiple adjacent JSDoc comments with different numbers of ' +
  32. '@param tags, the doclets have different parameter lists.', function() {
  33. checkInequality(name, 'params.length');
  34. checkInequality(shape, 'params.length');
  35. });
  36. it('When a symbol has multiple adjacent JSDoc comments with different numbers of ' +
  37. '@returns tags, the doclets have different lists of return values.', function() {
  38. checkInequality(name, 'returns.length');
  39. checkInequality(shape, 'returns.length');
  40. });
  41. it('When a file contains a JSDoc comment with an @also tag, and the "tags.allowUnknownTags" ' +
  42. 'option is set to false, the file can be parsed without errors.', function() {
  43. var logger = require('jsdoc/util/logger');
  44. var allowUnknownTags = Boolean(env.conf.tags.allowUnknownTags);
  45. var errors = [];
  46. function errorListener(err) {
  47. errors.push(err);
  48. }
  49. logger.addListener('logger:error', errorListener);
  50. env.conf.tags.allowUnknownTags = false;
  51. jasmine.getDocSetFromFile('test/fixtures/also2.js');
  52. expect(errors[0]).not.toBeDefined();
  53. logger.removeListener('logger:error', errorListener);
  54. env.conf.tags.allowUnknownTags = allowUnknownTags;
  55. });
  56. });