@mixes and @mixin tests added

This commit is contained in:
mathematicalcoffee 2013-02-15 13:04:57 +10:00
parent 896f1bd909
commit 0e8e1664f7
3 changed files with 59 additions and 0 deletions

27
test/fixtures/mixintag.js vendored Normal file
View File

@ -0,0 +1,27 @@
/**
* This provides methods used for event handling. It's not meant to
* be used directly, except as a provider of related methods.
*
* @mixin
*/
var Eventful = {
/** fires something. */
fires: function () {},
/** handles a signal. */
on: function () {}
};
/**
* @constructor
* @mixes Eventful
*/
var FormButton = function() {
};
/** @mixin AnotherMixin*/
/** I mix in multiple things
* @constructor MyClass
* @mixes Eventful
* @mixes AnotherMixin */

View File

@ -0,0 +1,19 @@
describe("@mixes tag", function() {
var docSet = jasmine.getDocSetFromFile('test/fixtures/mixintag.js'),
FormButton = docSet.getByLongname('FormButton')[0],
MyClass = docSet.getByLongname('MyClass')[0];
it("When a symbol has a @mixes tag, it gets an array property 'mixes' with the name of the mixin", function() {
expect(FormButton.mixes).toBeDefined();
expect(Array.isArray(FormButton.mixes)).toBe(true);
expect(FormButton.mixes.length).toBe(1);
expect(FormButton.mixes[0]).toBe('Eventful');
});
it("A symbol can @mixes multiple mixins and they are all added.", function() {
expect(MyClass.mixes).toBeDefined();
expect(MyClass.mixes.length).toBe(2);
expect(MyClass.mixes).toContain('Eventful');
expect(MyClass.mixes).toContain('AnotherMixin');
});
});

View File

@ -0,0 +1,13 @@
describe("@mixin tag", function() {
var docSet = jasmine.getDocSetFromFile('test/fixtures/mixintag.js'),
Eventful = docSet.getByLongname('Eventful')[0],
Mixin = docSet.getByLongname('AnotherMixin')[0];
it("When a symbol has a @mixin tag, the doclet's 'kind' property is set to 'mixin'", function() {
expect(Eventful.kind).toBe('mixin');
});
it("When a symbol has a @mixin tag, its name is set to the tag's value (if present)", function() {
expect(Mixin).toBeDefined();
});
});