mixins.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. 'use strict';
  2. var augment = require('jsdoc/augment');
  3. var name = require('jsdoc/name');
  4. describe('mixins', function() {
  5. describe('doclet augmentation', function() {
  6. var docSet = jasmine.getDocSetFromFile('test/fixtures/mixintag2.js');
  7. augment.augmentAll(docSet.doclets);
  8. it('should create doclets for mixed-in symbols', function() {
  9. var objectBMethod = docSet.getByLongname('module:mixy.ObjectB.method')[0];
  10. expect(objectBMethod).toBeDefined();
  11. expect(objectBMethod.memberof).toBe('module:mixy.ObjectB');
  12. });
  13. it('should set the "mixes" property correctly on first-generation mixers', function() {
  14. var objectBMethod = docSet.getByLongname('module:mixy.ObjectB.method')[0];
  15. expect(Array.isArray(objectBMethod.mixes)).toBe(true);
  16. expect(objectBMethod.mixes.length).toBe(1);
  17. expect(objectBMethod.mixes[0]).toBe('module:mixy.ObjectA.method');
  18. });
  19. it('should set the "mixes" property correctly on second-generation mixers', function() {
  20. var objectCMethod = docSet.getByLongname('module:mixy.ObjectC.method')[0];
  21. expect(Array.isArray(objectCMethod.mixes)).toBe(true);
  22. expect(objectCMethod.mixes.length).toBe(1);
  23. expect(objectCMethod.mixes[0]).toBe('module:mixy.ObjectB.method');
  24. });
  25. it('should work with mixed-in doclets whose names are specified in the comment', function() {
  26. var superSweetStatic = docSet.getByLongname('module:mixy.ObjectC.superSweet')[0];
  27. var superSweetInstance = docSet.getByLongname('module:mixy.ClassB#superSweet')[0];
  28. expect(superSweetInstance).toBeDefined();
  29. expect(superSweetInstance.comment).toBe(superSweetStatic.comment);
  30. });
  31. describe('classes and mixins', function() {
  32. it('should define symbols mixed into a class as instance members', function() {
  33. var classAMethod = docSet.getByLongname('module:mixy.ClassA#method')[0];
  34. expect(classAMethod).toBeDefined();
  35. expect(classAMethod.scope).toBe(name.SCOPE.NAMES.INSTANCE);
  36. expect(classAMethod.memberof).toBe('module:mixy.ClassA');
  37. });
  38. });
  39. });
  40. });