From 0e8e1664f75aa078b3f34b046913987fdd318a64 Mon Sep 17 00:00:00 2001 From: mathematicalcoffee Date: Fri, 15 Feb 2013 13:04:57 +1000 Subject: [PATCH] @mixes and @mixin tests added --- test/fixtures/mixintag.js | 27 +++++++++++++++++++++++++++ test/specs/tags/mixestag.js | 19 +++++++++++++++++++ test/specs/tags/mixintag.js | 13 +++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 test/fixtures/mixintag.js create mode 100644 test/specs/tags/mixestag.js create mode 100644 test/specs/tags/mixintag.js diff --git a/test/fixtures/mixintag.js b/test/fixtures/mixintag.js new file mode 100644 index 00000000..07dc085d --- /dev/null +++ b/test/fixtures/mixintag.js @@ -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 */ + diff --git a/test/specs/tags/mixestag.js b/test/specs/tags/mixestag.js new file mode 100644 index 00000000..6bb4f827 --- /dev/null +++ b/test/specs/tags/mixestag.js @@ -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'); + }); +}); diff --git a/test/specs/tags/mixintag.js b/test/specs/tags/mixintag.js new file mode 100644 index 00000000..4c928fb2 --- /dev/null +++ b/test/specs/tags/mixintag.js @@ -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(); + }); +});