Permalink
Browse files

Added the MODEL_JS and TESTMODEL_JS templates.

  • Loading branch information...
1 parent 6c2fa12 commit fd0f10834a7100adac2b0bc52c4dca914d37bc31 @mr-rock mr-rock committed Mar 11, 2012
Showing with 64 additions and 1 deletion.
  1. +64 −1 .alice/javascript
View
@@ -36,4 +36,67 @@ TESTMODULE_JS += "\n\n\tdescribe('\#example', function() {\
\n\t\t\tdone();\
\n\t\t});\
\n\t});\
-\n})"
+\n})"
+
+MODEL_JS = "var $(NAME) = exports = module.exports = function $(NAME)() {\
+\n\tvar counter = -1;\
+\n\tvar index = 0;\
+\n\n\tfunction method1() {\
+\n\t\treturn '\#method1()';\
+\n\t}\
+\n\n\tfunction method2(text) {\
+\n\t\treturn text;\
+\n\t}\
+\n\n\treturn {\
+\n\t\tindex: index,\
+\n\t\tmethod1: method1,\
+\n\t\tmethod2: method2\
+\n\t}\
+\n};"
+
+ifeq "$(GROUP)" ""
+TESTMODEL_JS = "describe('$(NAME)', function() {\
+\n\tvar $(NAME) = require('../../$(LIBRARIES_DIRECTORY)/$(NAME_CAMELIZED)');"
+else
+TESTMODEL_JS = "describe('$(APP) > $(NAME)', function() {\
+\n\tvar $(NAME) = require('../../../$(LIBRARIES_DIRECTORY)/$(GROUP_CAMELIZED)/$(NAME_CAMELIZED));"
+endif
+
+TESTMODEL_JS += "\n\tvar instance = new $(NAME)();\
+\n\n\tdescribe('\#counter', function() {\
+\n\t\tit('should not exist', function(done) {\
+\n\t\t\tinstance.should.not.have.property('counter');\
+\n\t\t\tdone();\
+\n\t\t});\
+\n\t});\
+\n\n\tdescribe('\#index', function() {\
+\n\t\tit('should exist', function(done) {\
+\n\t\t\tinstance.should.have.property('index');\
+\n\t\t\tdone();\
+\n\t\t});\
+\n\t\tit('should be 0', function(done) {\
+\n\t\t\tinstance.index.should.eql(0);\
+\n\t\t\tdone();\
+\n\t\t});\
+\n\t});\
+\n\n\tdescribe('\#method1()', function() {\
+\n\t\tit('should exist', function(done) {\
+\n\t\t\tinstance.should.have.property('method1');\
+\n\t\t\tdone();\
+\n\t\t});\
+\n\t\tit('should return a predefined text', function(done) {\
+\n\t\t\tinstance.method1().should.eql('\#method1()');\
+\n\t\t\tdone();\
+\n\t\t});\
+\n\t});\
+\n\n\tdescribe('\#method2()', function() {\
+\n\t\tit('should exist', function(done) {\
+\n\t\t\tinstance.should.have.property('method2');\
+\n\t\t\tdone();\
+\n\t\t});\
+\n\t\tit('should return a given text', function(done) {\
+\n\t\t\tinstance.method2('text').should.eql('text');\
+\n\t\t\tdone();\
+\n\t\t});\
+\n\t});\
+\n});"

0 comments on commit fd0f108

Please sign in to comment.