Commits

Anonymous committed e92fe7a

More tests

  • Participants
  • Parent commits 5c93f73

Comments (0)

Files changed (9)

dist/amd/recipe.js

     
     // no extensions available for the targeted build platform
     
-    function recipe() {
-    }
-    
-    recipe.define = function(opts) {
-    	return new Recipe(opts);
+    var recipe = {
+    	define: function(opts) {
+    		return new Recipe(opts);
+    	}
     };
     
     return typeof recipe != 'undefined' ? recipe : undefined;

dist/commonjs/recipe.js

     
 };
 
-function recipe() {
-}
-
-recipe.define = function(opts) {
-	return new Recipe(opts);
+var recipe = {
+	define: function(opts) {
+		return new Recipe(opts);
+	}
 };
 
 if (typeof recipe != 'undefined') {

dist/glob/recipe.js

     
     // no extensions available for the targeted build platform
     
-    function recipe() {
-    }
-    
-    recipe.define = function(opts) {
-    	return new Recipe(opts);
+    var recipe = {
+    	define: function(opts) {
+    		return new Recipe(opts);
+    	}
     };
     
     if (typeof recipe != 'undefined') {
 
 //= core/{{ packageType }}/recipe-ext  : core/recipe-noext
 
-function recipe() {
-}
-
-recipe.define = function(opts) {
-	return new Recipe(opts);
+var recipe = {
+	define: function(opts) {
+		return new Recipe(opts);
+	}
 };

test/browser/index.html

 </head>
 <body>
   <div id="mocha"></div>
-  <script src="../metadata.js"></script>
+  <script src="../parser.js"></script>
+  <script src="../section-deps.js"></script>
+  <script src="../section-variants.js"></script>
   <script>
     $(function () {
       mocha.run();

test/metadata.js

-var recipe = require('../dist/commonjs/recipe'),
-    expect = require('expect.js'),
-    sniff = require('sniff'),
-    samples = {
-        simple:
-        '# dsc: small JS library for DOM class manipulation\n' +
-        '# url: https://github.com/DamonOehlman/classtweak\n' +
-        '# bug: https://github.com/DamonOehlman/classtweak/issues\n' +
-        '# dep: jquery\n\n' +
-        '[core]\n' +
-        'js <= github://DamonOehlman/classtweak/classtweak.js',
-
-        'alternative format':
-        '# dsc: Another test library\n' +
-        '# url: http://test.com/\n' +
-        '# req: jquery\n\n' +
-        '[core]\n' +
-        'js <= github://DamonOehlman/classtweak/classtweak.js',
-
-        'no section declaration':
-        '# dsc: No Section Test\n' +
-        '# url: http://test.com/\n' +
-        '# req: jquery\n\n' +
-        'js <= github://DamonOehlman/classtweak/classtweak.js',
-
-        'comment-less':
-        'dsc: Commentless recipe\n' +
-        'url: http://test.com/\n' +
-        'req: jquery\n\n' +
-        'js <= github://DamonOehlman/classtweak/classtweak.js',
-
-        'leading-spaces':
-        ' dsc: Leading Spaces Recipe\n' +
-        ' url: http://test.com/\n' +
-        '      req: jquery\n\n' +
-        'js <= github://DamonOehlman/classtweak/classtweak.js',
-
-        'no-metadata':
-        'js <= github://DamonOehlman/classtweak/classtweak.js'
-    };
-
-function checkSample(sampleName) {
-    var testRecipe = recipe.define(samples[sampleName]);
-
-    describe('(' + sampleName + ') metadata', function() {
-        it('should have a description', function() {
-            expect(testRecipe.desc).to.be.ok();
-        });
-
-        it('should have a url', function() {
-            expect(testRecipe.url).to.be.ok();
-        });
-
-        it('should require jquery', function() {
-            expect(testRecipe.requirements.length).to.be.above(0);
-            expect(testRecipe.requirements[0]).to.equal('jquery');
-        });
-    });
-
-    checkSampleSection(sampleName);
-}
-
-function checkSampleSection(sampleName) {
-    var testRecipe = recipe.define(samples[sampleName]);
-
-    describe('(' + sampleName + ') core section', function() {
-        it('should have a core section', function() {
-            expect(testRecipe.sections.core).to.be.ok();
-        });
-
-        it('should have data for the core section', function() {
-            var core = testRecipe.sections.core;
-            
-            expect(core.targets.js).to.be.ok();
-            expect(sniff(core.targets.js)).to.equal('array');
-            expect(core.targets.js.length).to.equal(1);
-            expect(core.targets.js[0]).to.equal('github://DamonOehlman/classtweak/classtweak.js');
-        });
-    });
-}
-
-describe('recipe metadata tests', function() {
-    checkSample('simple');
-    checkSample('alternative format');
-    checkSample('no section declaration');
-    checkSample('comment-less');
-    checkSample('leading-spaces');
-
-    checkSampleSection('no-metadata');
-});
+var recipe = require('../dist/commonjs/recipe'),
+    expect = require('expect.js'),
+    sniff = require('sniff'),
+    samples = {
+        simple:
+        '# dsc: small JS library for DOM class manipulation\n' +
+        '# url: https://github.com/DamonOehlman/classtweak\n' +
+        '# bug: https://github.com/DamonOehlman/classtweak/issues\n' +
+        '# dep: jquery\n\n' +
+        '[core]\n' +
+        'js <= github://DamonOehlman/classtweak/classtweak.js',
+
+        'alternative format':
+        '# dsc: Another test library\n' +
+        '# url: http://test.com/\n' +
+        '# req: jquery\n\n' +
+        '[core]\n' +
+        'js <= github://DamonOehlman/classtweak/classtweak.js',
+
+        'no section declaration':
+        '# dsc: No Section Test\n' +
+        '# url: http://test.com/\n' +
+        '# req: jquery\n\n' +
+        'js <= github://DamonOehlman/classtweak/classtweak.js',
+
+        'comment-less':
+        'dsc: Commentless recipe\n' +
+        'url: http://test.com/\n' +
+        'req: jquery\n\n' +
+        'js <= github://DamonOehlman/classtweak/classtweak.js',
+
+        'leading-spaces':
+        ' dsc: Leading Spaces Recipe\n' +
+        ' url: http://test.com/\n' +
+        '      req: jquery\n\n' +
+        'js <= github://DamonOehlman/classtweak/classtweak.js',
+
+        'no-metadata':
+        'js <= github://DamonOehlman/classtweak/classtweak.js'
+    };
+
+function checkSample(sampleName) {
+    var testRecipe = recipe.define(samples[sampleName]);
+
+    describe('(' + sampleName + ') metadata', function() {
+        it('should have a description', function() {
+            expect(testRecipe.desc).to.be.ok();
+        });
+
+        it('should have a url', function() {
+            expect(testRecipe.url).to.be.ok();
+        });
+
+        it('should require jquery', function() {
+            expect(testRecipe.requirements.length).to.be.above(0);
+            expect(testRecipe.requirements[0]).to.equal('jquery');
+        });
+    });
+
+    checkSampleSection(sampleName);
+}
+
+function checkSampleSection(sampleName) {
+    var testRecipe = recipe.define(samples[sampleName]);
+
+    describe('(' + sampleName + ') core section', function() {
+        it('should have a core section', function() {
+            expect(testRecipe.sections.core).to.be.ok();
+        });
+
+        it('should have data for the core section', function() {
+            var core = testRecipe.sections.core;
+            
+            expect(core.targets.js).to.be.ok();
+            expect(sniff(core.targets.js)).to.equal('array');
+            expect(core.targets.js.length).to.equal(1);
+            expect(core.targets.js[0]).to.equal('github://DamonOehlman/classtweak/classtweak.js');
+        });
+    });
+}
+
+describe('recipe parser tests', function() {
+    checkSample('simple');
+    checkSample('alternative format');
+    checkSample('no section declaration');
+    checkSample('comment-less');
+    checkSample('leading-spaces');
+
+    checkSampleSection('no-metadata');
+});

test/section-deps.js

+var recipe = require('../dist/commonjs/recipe'),
+    expect = require('expect.js'),
+    sniff = require('sniff');
+
+describe('section dependency recipe checks', function() {
+    var recipeText =
+        'dsc: Section Deps Test\n' +
+        '[core]\n' +
+        'js <= github://DamonOehlman/classtweak/classtweak.js\n' +
+        '[awesome]\n' +
+        'dep: jquery\n' +
+        'js <= github://DamonOehlman/matchme/dist/{{ packageType }}/matchme.js',
+    testRecipe = recipe.define(recipeText);
+
+
+    it('should have a description', function() {
+        expect(testRecipe.desc).to.equal('Section Deps Test');
+    });
+
+    it('should have an awesome section', function() {
+        expect(testRecipe.sections.awesome).to.be.ok();
+    });
+
+    it('find a dependency of jquery for the awesome section', function() {
+        var testSection = testRecipe.sections.awesome;
+
+        expect(sniff(testSection.requirements)).to.equal('array');
+        expect(testSection.requirements.length).to.be.above(0);
+        expect(testSection.requirements[0]).to.equal('jquery');
+    });
+});

test/section-variants.js

+var recipe = require('../dist/commonjs/recipe'),
+    expect = require('expect.js'),
+    sniff = require('sniff');
+
+describe('section dependency recipe checks', function() {
+    var recipeText =
+            'dsc: Section Variants Test\n' +
+            '[core]\n' +
+            'js <= github://DamonOehlman/classtweak/classtweak.js\n' +
+            '[addin]\n' +
+            'variants: dropdown, modal\n' +
+            'js <= github://twitter/bootstrap/js/bootstrap-$addin.js',
+    testRecipe = recipe.define(recipeText);
+
+
+    it('should have a description', function() {
+        expect(testRecipe.desc).to.equal('Section Variants Test');
+    });
+
+    it('should have an addin section', function() {
+        expect(testRecipe.sections.addin).to.be.ok();
+    });
+
+    it('find variants for the addin section', function() {
+        var testSection = testRecipe.sections.addin;
+
+        expect(sniff(testSection.requirements)).to.equal('array');
+        expect(testSection.requirements.length).to.equal(0);
+        expect(testSection.variants.length).to.equal(2);
+        expect(testSection.variants[0].name).to.equal('dropdown');
+    });
+});