UNPKG

2.57 kBtext/coffeescriptView Raw
1cc = require '../lib/coffeecup'
2
3describe 'coffeescript helper', ->
4 describe '#coffeescript()', ->
5 it 'function should render', ->
6 t = -> coffeescript -> alert 'hi'
7 cc.render(t).should.equal "<script>var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\n return alert('hi');\n }).call(this);</script>"
8 it 'string should render', ->
9 t = -> coffeescript "alert 'hi'"
10 cc.render(t).should.equal "<script type=\"text/coffeescript\">alert 'hi'</script>"
11 it 'object should render', ->
12 t = -> coffeescript src: 'script.coffee'
13 cc.render(t).should.equal "<script src=\"script.coffee\" type=\"text/coffeescript\"></script>"
14
15describe 'coffeescript helper optimized', ->
16 describe '#coffeescript()', ->
17 it 'function should render', ->
18 t = -> coffeescript -> alert 'hi'
19 cc.render(t, optimize: true).should.equal "<script>var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\n return alert('hi');\n }).call(this);</script>"
20 it 'string should render', ->
21 t = -> coffeescript "alert 'hi'"
22 cc.render(t, optimize: true).should.equal "<script type=\"text/coffeescript\">alert 'hi'</script>"
23 it 'object should render', ->
24 t = -> coffeescript src: 'script.coffee'
25 cc.render(t, optimize: true).should.equal "<script src=\"script.coffee\" type=\"text/coffeescript\"></script>"