This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Add tests & generators.

  • Loading branch information...
paulmillr committed Aug 8, 2012
1 parent 0a7d85d commit 5fe2b22351dc724dc8455100444660088647dcb3
Showing with 12,825 additions and 5 deletions.
  1. +2 −5 config.coffee
  2. +5 −0 generators/collection/collection.coffee.hbs
  3. +11 −0 generators/collection/generator.json
  4. 0 test/spec.coffee → generators/collection_test/collection_test.coffee.hbs
  5. +9 −0 generators/collection_test/generator.json
  6. +5 −0 generators/collection_view/collection_view.coffee.hbs
  7. +9 −0 generators/collection_view/generator.json
  8. +3 −0 generators/controller/controller.coffee.hbs
  9. +11 −0 generators/controller/generator.json
  10. +5 −0 generators/controller_test/controller_test.coffee.hbs
  11. +9 −0 generators/controller_test/generator.json
  12. 0 generators/generator/generated_file.coffee.hbs
  13. +13 −0 generators/generator/generator.json
  14. +9 −0 generators/generator/generator.json.hbs
  15. +11 −0 generators/model/generator.json
  16. +3 −0 generators/model/model.coffee.hbs
  17. +9 −0 generators/model_test/generator.json
  18. +5 −0 generators/model_test/model_test.coffee.hbs
  19. +9 −0 generators/page_view/generator.json
  20. +5 −0 generators/page_view/page_view.coffee.hbs
  21. +9 −0 generators/style/generator.json
  22. +1 −0 generators/style/style.styl.hbs
  23. +9 −0 generators/template/generator.json
  24. 0 generators/template/template.hbs.hbs
  25. +11 −0 generators/view/generator.json
  26. +5 −0 generators/view/view.coffee.hbs
  27. +9 −0 generators/view_test/generator.json
  28. +5 −0 generators/view_test/view_test.coffee.hbs
  29. +24 −0 test/assets/test/index.html
  30. +11 −0 test/models/header_test.coffee
  31. +8 −0 test/test-helpers.coffee
  32. +3,590 −0 test/vendor/scripts/chai-1.2.0.js
  33. +4,597 −0 test/vendor/scripts/mocha-1.3.2.js
  34. +4,081 −0 test/vendor/scripts/sinon-1.4.2.js
  35. +95 −0 test/vendor/scripts/sinon-chai-2.1.2.js
  36. +199 −0 test/vendor/styles/mocha-1.3.2.css
  37. +27 −0 test/views/header_view_test.coffee
  38. +11 −0 test/views/home_page_view_test.coffee
View
@@ -2,13 +2,14 @@ exports.config =
# See http://brunch.readthedocs.org/en/latest/config.html for documentation.
files:
javascripts:
- defaultExtension: 'coffee'
joinTo:
'javascripts/app.js': /^app/
'javascripts/vendor.js': /^vendor/
'test/javascripts/test.js': /^test(\/|\\)(?!vendor)/
'test/javascripts/test-vendor.js': /^test(\/|\\)(?=vendor)/
order:
+ # Files in `vendor` directories are compiled before other files
+ # even if they aren't specified in order.before.
before: [
'vendor/scripts/console-helper.js',
'vendor/scripts/jquery-1.7.2.js',
@@ -17,15 +18,11 @@ exports.config =
]
stylesheets:
- defaultExtension: 'styl'
joinTo:
'stylesheets/app.css': /^(app|vendor)/
'test/stylesheets/test.css': /^test/
order:
before: ['vendor/styles/bootstrap.css']
templates:
- defaultExtension: 'hbs'
joinTo: 'javascripts/app.js'
-
- framework: 'chaplin'
@@ -0,0 +1,5 @@
+Collection = require 'models/base/collection'
+{{#camelize}}{{name}}{{/camelize}} = require 'models/{{name}}'
+
+module.exports = class {{#camelize}}{{pluralName}}{{/camelize}} extends Collection
+ model: {{#camelize}}{{name}}{{/camelize}}
@@ -0,0 +1,11 @@
+{
+ "files": [
+ {
+ "from": "collection.coffee.hbs",
+ "to": "app/models/{{name}}.coffee"
+ }
+ ],
+ "dependencies": [
+ {"name": "collection_test", "params": "{{name}}"}
+ ]
+}
File renamed without changes.
@@ -0,0 +1,9 @@
+{
+ "files": [
+ {
+ "from": "collection_test.coffee.hbs",
+ "to": "test/models/{{name}}_test.coffee"
+ }
+ ],
+ "dependencies": []
+}
@@ -0,0 +1,5 @@
+CollectionView = require 'views/base/collection_view'
+{{#camelize}}{{name}}{{/camelize}} = require 'views/{{name}}_view'
+
+module.exports = class {{#camelize}}{{pluralName}}{{/camelize}}View extends CollectionView
+ itemView: {{#camelize}}{{name}}{{/camelize}}
@@ -0,0 +1,9 @@
+{
+ "files": [
+ {
+ "from": "collection_view.coffee.hbs",
+ "to": "app/views/{{name}}.coffee"
+ }
+ ],
+ "dependencies": []
+}
@@ -0,0 +1,3 @@
+Controller = require 'controllers/base/controller'
+
+module.exports = class {{#camelize}}{{pluralName}}{{/camelize}}Controller extends Controller
@@ -0,0 +1,11 @@
+{
+ "files": [
+ {
+ "from": "controller.coffee.hbs",
+ "to": "app/controllers/{{name}}_controller.coffee"
+ }
+ ],
+ "dependencies": [
+ {"name": "controller_test", "params": "{{name}}"}
+ ]
+}
@@ -0,0 +1,5 @@
+{{#camelize}}{{name}}{{/camelize}} = require 'models/{{name}}'
+
+describe '{{#camelize}}{{name}}{{/camelize}}', ->
+ beforeEach ->
+ @model = new {{#camelize}}{{name}}{{/camelize}}()
@@ -0,0 +1,9 @@
+{
+ "files": [
+ {
+ "from": "controller_test.coffee.hbs",
+ "to": "test/controllers/{{name}}_controller_test.coffee"
+ }
+ ],
+ "dependencies": []
+}
@@ -0,0 +1,13 @@
+{
+ "files": [
+ {
+ "from": "generator.json.hbs",
+ "to": "generators/{{name}}/generator.json"
+ },
+ {
+ "from": "generated_file.coffee.hbs",
+ "to": "generators/{{name}}/{{name}}.coffee.hbs"
+ }
+ ],
+ "dependencies": []
+}
@@ -0,0 +1,9 @@
+{
+ "files": [
+ {
+ "from": "{{name}}.coffee.hbs",
+ "to": "app/file.coffee"
+ }
+ ],
+ "dependencies": []
+}
@@ -0,0 +1,11 @@
+{
+ "files": [
+ {
+ "from": "model.coffee.hbs",
+ "to": "app/models/{{name}}.coffee"
+ }
+ ],
+ "dependencies": [
+ {"name": "model_test", "params": "{{name}}"}
+ ]
+}
@@ -0,0 +1,3 @@
+Model = require 'models/base/model'
+
+module.exports = class {{#camelize}}{{name}}{{/camelize}} extends Model
@@ -0,0 +1,9 @@
+{
+ "files": [
+ {
+ "from": "model_test.coffee.hbs",
+ "to": "test/models/{{name}}.coffee"
+ }
+ ],
+ "dependencies": []
+}
@@ -0,0 +1,5 @@
+{{#camelize}}{{name}}{{/camelize}} = require 'models/{{name}}'
+
+describe '{{#camelize}}{{name}}{{/camelize}}', ->
+ beforeEach ->
+ @model = new {{#camelize}}{{name}}{{/camelize}}()
@@ -0,0 +1,9 @@
+{
+ "files": [
+ {
+ "from": "page_view.coffee.hbs",
+ "to": "app/views/{{name}}_page_view.coffee"
+ }
+ ],
+ "dependencies": []
+}
@@ -0,0 +1,5 @@
+PageView = require 'views/base/page_view'
+template = require 'views/templates/{{name}}_page'
+
+module.exports = class {{#camelize}}{{name}}{{/camelize}}PageView extends View
+ template: template
@@ -0,0 +1,9 @@
+{
+ "files": [
+ {
+ "from": "file.styl.hbs",
+ "to": "app/views/styles/{{name}}.styl"
+ }
+ ],
+ "dependencies": []
+}
@@ -0,0 +1 @@
+@import 'nib'
@@ -0,0 +1,9 @@
+{
+ "files": [
+ {
+ "from": "template.hbs.hbs",
+ "to": "app/views/templates/{{name}}.hbs"
+ }
+ ],
+ "dependencies": []
+}
No changes.
@@ -0,0 +1,11 @@
+{
+ "files": [
+ {
+ "from": "view.coffee.hbs",
+ "to": "app/views/{{name}}_view.coffee"
+ }
+ ],
+ "dependencies": [
+ {"name": "view_test", "params": "{{name}}"}
+ ]
+}
@@ -0,0 +1,5 @@
+View = require 'views/base/view'
+template = require 'views/templates/{{name}}'
+
+module.exports = class {{#camelize}}{{name}}{{/camelize}}View extends View
+ template: template
@@ -0,0 +1,9 @@
+{
+ "files": [
+ {
+ "from": "view_test.coffee.hbs",
+ "to": "test/views/{{name}}_view.coffee"
+ }
+ ],
+ "dependencies": []
+}
@@ -0,0 +1,5 @@
+{{#camelize}}{{name}}{{/camelize}}View = require 'views/{{name}}_view'
+
+describe '{{#camelize}}{{name}}{{/camelize}}View', ->
+ beforeEach ->
+ @view = new {{#camelize}}{{name}}{{/camelize}}View()
@@ -0,0 +1,24 @@
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Mocha Tests</title>
+ <link rel="stylesheet" href="stylesheets/test.css" />
+
+ <script src="../javascripts/vendor.js"></script>
+ <script src="../javascripts/app.js"></script>
+ <script src="javascripts/test-vendor.js"></script>
+ <script>
+ mocha.setup('bdd');
+ window.expect = chai.expect;
+ </script>
+ <script src="javascripts/test.js"></script>
+ <script>
+ $(function() {
+ mocha.run();
+ });
+ </script>
+</head>
+<body>
+ <div id="mocha"></div>
+</body>
+</html>
@@ -0,0 +1,11 @@
+Header = require 'models/header'
+
+describe 'Header', ->
+ beforeEach ->
+ @model = new Header()
+
+ afterEach ->
+ @model.dispose()
+
+ it 'should contain 4 items', ->
+ expect(@model.get 'items').to.have.length 4
View
@@ -0,0 +1,8 @@
+# This file will be automatically required when using `brunch test` command.
+chai = require 'chai'
+sinonChai = require 'sinon-chai'
+chai.use sinonChai
+
+module.exports =
+ expect: chai.expect
+ sinon: require 'sinon'
Oops, something went wrong.

0 comments on commit 5fe2b22

Please sign in to comment.