markdown.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. 'use strict';
  2. var env = require('jsdoc/env');
  3. var path = require('jsdoc/path');
  4. describe('markdown plugin', function() {
  5. var pluginPath = 'plugins/markdown';
  6. var pluginPathResolved = path.join(env.dirname, pluginPath);
  7. var plugin = require(pluginPathResolved);
  8. var docSet = jasmine.getDocSetFromFile('plugins/test/fixtures/markdown.js');
  9. // TODO: more tests; refactor the plugin so multiple settings can be tested
  10. it('should process the correct tags by default', function() {
  11. var myClass = docSet.getByLongname('MyClass')[0];
  12. plugin.handlers.newDoclet({ doclet: myClass });
  13. [
  14. myClass.author[0],
  15. myClass.classdesc,
  16. myClass.description,
  17. myClass.exceptions[0].description,
  18. myClass.params[0].description,
  19. myClass.properties[0].description,
  20. myClass.returns[0].description,
  21. myClass.see,
  22. myClass.summary
  23. ].forEach(function(value) {
  24. // if we processed the value, it should be wrapped in a <p> tag
  25. expect( /^<p>(?:.+)<\/p>$/.test(value) ).toBe(true);
  26. });
  27. });
  28. it('should unescape &quot; entities in inline tags, but not elsewhere', function() {
  29. var myOtherClass = docSet.getByLongname('MyOtherClass')[0];
  30. plugin.handlers.newDoclet({ doclet: myOtherClass });
  31. expect(myOtherClass.description).toContain('chat."#channel"."say-\\"hello\\""');
  32. expect(myOtherClass.description).toContain('&quot;See&quot;');
  33. });
  34. describe('@see tag support', function() {
  35. var foo = docSet.getByLongname('foo')[0];
  36. var bar = docSet.getByLongname('bar')[0];
  37. it('should parse @see tags containing links', function() {
  38. plugin.handlers.newDoclet({ doclet: foo });
  39. expect(typeof foo).toEqual('object');
  40. expect(foo.see[0]).toEqual('<p><a href="http://nowhere.com">Nowhere</a></p>');
  41. });
  42. it('should not parse @see tags that do not contain links', function() {
  43. plugin.handlers.newDoclet({ doclet: bar });
  44. expect(typeof bar).toEqual('object');
  45. expect(bar.see[0]).toEqual('AnObject#myProperty');
  46. });
  47. });
  48. });