123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- 'use strict';
- describe('this', function() {
- describe('attaching members to "this"', function() {
- var docSet = jasmine.getDocSetFromFile('test/fixtures/this.js');
- var found1 = docSet.getByLongname('Singer#tralala');
- var found2 = docSet.getByLongname('Singer#isSinging');
- describe('in a contructor', function() {
- it('should have a longname like Constructor#member', function() {
- expect(found1.length).toBe(1);
- });
- it('should have a correct short name', function() {
- expect(found1[0].name).toBe('tralala');
- });
- it('should have a correct memberof', function() {
- expect(found1[0].memberof).toBe('Singer');
- });
- it('should default to an "instance" scope', function() {
- expect(found1[0].scope).toBe('instance');
- });
- });
- describe('in a method of a constructor', function() {
- it('should have a longname like Constructor#member', function() {
- expect(found2.length).toBe(1);
- });
- it('should have a correct short name', function() {
- expect(found2[0].name).toBe('isSinging');
- });
- it('should have a correct memberof', function() {
- expect(found2[0].memberof).toBe('Singer');
- });
- it('should default to an "instance" scope', function() {
- expect(found2[0].scope).toBe('instance');
- });
- });
- });
- describe('when a contructor is nested inside another constructor', function() {
- var docSet = jasmine.getDocSetFromFile('test/fixtures/this2.js');
- var found = docSet.getByLongname('TemplateBuilder#Template#rendered');
- it('should have a longname like Constructor#Constructor#member', function() {
- expect(found.length).toBe(1);
- });
- it('should have a correct short name', function() {
- expect(found[0].name).toBe('rendered');
- });
- it('should have a correct memberof', function() {
- expect(found[0].memberof).toBe('TemplateBuilder#Template');
- });
- it('should default to an "instance" scope', function() {
- expect(found[0].scope).toBe('instance');
- });
- });
- describe('When a this is assigned to inside a non-constructor function', function() {
- var docSet = jasmine.getDocSetFromFile('test/fixtures/this3.js');
- var found = docSet.getByLongname('position');
- it('should have a global member name like "member"', function() {
- expect(found.length).toBe(1);
- });
- it('should have a correct short name', function() {
- expect(found[0].name).toBe('position');
- });
- it('should have a correct memberof', function() {
- expect(found[0].memberof).toBeUndefined();
- });
- });
- describe('When "this" is assigned inside an explicit definition of the class constructor', function() {
- var docSet = jasmine.getDocSetFromFile('test/fixtures/this4.js');
- var found = docSet.getByLongname('Template#render');
- it('should have a longname like Constructor#member', function() {
- expect(found.length).toBe(1);
- });
- it('should have the correct name', function() {
- expect(found[0].name).toBe('render');
- });
- it('should have the correct memberof', function() {
- expect(found[0].memberof).toBe('Template');
- });
- });
- describe('When "this" is assigned in a chained declaration in a module', function() {
- var docSet = jasmine.getDocSetFromFile('test/fixtures/this5.js');
- var found = docSet.getByLongname('module:template.Template#view');
- it('should have a longname like Constructor#member', function() {
- expect(found.length).toBe(1);
- });
- it('should have the correct name', function() {
- expect(found[0].name).toBe('view');
- });
- it('should have the correct memberof', function() {
- expect(found[0].memberof).toBe('module:template.Template');
- });
- });
- describe('When `this` is within the constructor in a class that has an `@alias` tag within a module', function() {
- var docSet = jasmine.getDocSetFromFile('test/fixtures/this6.js');
- var someProperty = docSet.getByLongname('module:example#_someProperty')[0];
- it('should have the correct longname, name, and scope', function() {
- expect(someProperty).toBeDefined();
- expect(someProperty.name).toBe('_someProperty');
- expect(someProperty.scope).toBe('instance');
- });
- });
- describe('When a member is nested inside an objectlit "this" property inside a constructor', function() {
- var docSet = jasmine.getDocSetFromFile('test/fixtures/this-and-objectlit.js');
- var found = docSet.getByLongname('Page#parts.body.heading');
- it('should have a longname like Constructor#objlit.member', function() {
- expect(found.length).toBe(1);
- });
- it('should have a correct short name', function() {
- expect(found[0].name).toBe('heading');
- });
- it('should have a correct memberof', function() {
- expect(found[0].memberof).toBe('Page#parts.body');
- });
- it('should default to a "static" scope', function() {
- expect(found[0].scope).toBe('static');
- });
- });
- });
|