javascripts.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. var should = require('should')
  2. var polymer = require('../')
  3. describe("javascripts", function(){
  4. describe(".coffee", function(){
  5. var root = __dirname + "/fixtures/javascripts/coffee"
  6. var poly = polymer.root(root)
  7. it("should translate coffeescript to javascript", function(done){
  8. poly.render("main.coffee", function(errors, body){
  9. should.not.exist(errors)
  10. should.exist(body)
  11. done()
  12. })
  13. })
  14. it("should minify beyond preprocessor", function(done){
  15. poly.render("main.coffee", function(errors, body){
  16. should.not.exist(errors)
  17. body.should.not.include("\n\n")
  18. done()
  19. })
  20. })
  21. it("shouldn’t strip unused javascript when minifying", function(done){
  22. poly.render("unused.coffee", function(errors, body){
  23. should.not.exist(errors)
  24. body.should.include("alert")
  25. done()
  26. })
  27. })
  28. it("should return errors if invalid", function(done){
  29. poly.render("invalid.coffee", function(errors, body){
  30. should.exist(errors)
  31. should.not.exist(body)
  32. errors.should.have.property("name")
  33. errors.should.have.property("message")
  34. errors.should.have.property("stack")
  35. done()
  36. })
  37. })
  38. })
  39. // describe("browserify", function() {
  40. // var root = __dirname + "/fixtures/javascripts/browserify"
  41. // var poly = polymer.root(root)
  42. // process.chdir(root)
  43. // it("should require coffeescript file in coffeescript", function(done) {
  44. // poly.render("require_coffee.coffee", function(errors, body) {
  45. // should.not.exist(errors)
  46. // body.should.include("MODULE_NOT_FOUND")
  47. // done()
  48. // })
  49. // })
  50. // it("should require javascript file in coffeescript", function(done) {
  51. // poly.render("require_js.coffee", function(errors, body) {
  52. // should.not.exist(errors)
  53. // body.should.include("MODULE_NOT_FOUND")
  54. // done()
  55. // })
  56. // })
  57. // it("should require coffeescript file in javascript", function(done) {
  58. // poly.render("require_coffee.js", function(errors, body) {
  59. // should.not.exist(errors)
  60. // body.should.include("MODULE_NOT_FOUND")
  61. // done()
  62. // })
  63. // })
  64. // it("should require javascript file in javascript", function(done) {
  65. // poly.render("require_js.js", function(errors, body) {
  66. // should.not.exist(errors)
  67. // body.should.include("MODULE_NOT_FOUND")
  68. // done()
  69. // })
  70. // })
  71. // it("should skip commented require in coffeescript", function(done) {
  72. // poly.render("comment.coffee", function(errors, body) {
  73. // should.not.exist(errors)
  74. // body.should.not.include("MODULE_NOT_FOUND")
  75. // done()
  76. // })
  77. // })
  78. // it("should skip commented require in javascript", function(done) {
  79. // poly.render("comment.js", function(errors, body) {
  80. // should.not.exist(errors)
  81. // body.should.not.include("MODULE_NOT_FOUND")
  82. // done()
  83. // })
  84. // })
  85. // it("should skip already declared require in coffeescript", function(done) {
  86. // poly.render("declared.coffee", function(errors, body) {
  87. // should.not.exist(errors)
  88. // body.should.not.include("MODULE_NOT_FOUND")
  89. // done()
  90. // })
  91. // })
  92. // it("should skip already declared require in javascript", function(done) {
  93. // poly.render("declared.js", function(errors, body) {
  94. // should.not.exist(errors)
  95. // body.should.not.include("MODULE_NOT_FOUND")
  96. // done()
  97. // })
  98. // })
  99. // it("should require javascript file in heavily nested coffeescript", function(done) {
  100. // poly.render("nested/way/in/here/nested.coffee", function(errors, body) {
  101. // should.not.exist(errors)
  102. // body.should.include("MODULE_NOT_FOUND")
  103. // done()
  104. // })
  105. // })
  106. // it("should require javascript file in heavily nested javascript file", function(done) {
  107. // poly.render("nested/way/in/here/nested.js", function(errors, body) {
  108. // should.not.exist(errors)
  109. // body.should.include("MODULE_NOT_FOUND")
  110. // done()
  111. // })
  112. // })
  113. // })
  114. })