@@ -5,46 +5,51 @@ describe 'CommonCoffeeHandler', ->
55 beforeEach ->
66 @subject = new CommonCoffeeHandler ()
77
8- describe ' handle' , ->
8+ it ' resolves to a compiled module wrapper for CoffeeScript files' , ->
9+ path = " #{ __dirname } /../../fixture/valid/coffee.coffee"
10+ expected = [
11+ ' coffee'
12+ '''
13+ function () {
14+ var module = {};
915
10- it ' resolves to a compiled module wrapper for CoffeeScript files' , ->
11- path = " #{ __dirname } /../../fixture/valid/coffee.coffee"
12- expected = [
13- ' coffee'
14- '''
15- function () {
16- var module = {};
16+ (function() {
17+ var test;
1718
18- (function() {
19- var test;
19+ test = 'It works.';
2020
21- test = 'It works.';
21+ module.exports = function() {
22+ return [test, arguments];
23+ };
2224
23- module.exports = function() {
24- return [test, arguments];
25- };
25+ }).call(this);
2626
27- }).call(this);
27+ return module.exports.apply(this, arguments);
28+ }
29+ '''
30+ ]
2831
29- return module.exports.apply(this, arguments);
30- }
31- '''
32- ]
32+ return @subject .handle path
33+ .then (actual) ->
34+ assert .deepEqual actual, expected
3335
34- return @subject .handle path
35- .then (actual) ->
36- assert .deepEqual actual, expected
36+ it ' resolves to null for non-CoffeeScript files' , ->
37+ path = " #{ __dirname } /../../fixture/valid/other.other"
3738
38- it ' resolves to null for non-CoffeeScript files' , ->
39- path = " #{ __dirname } /../../fixture/valid/file"
39+ return @subject .handle path
40+ .then (actual) ->
41+ assert .isNull actual
4042
41- return @subject .handle path
42- .then (actual) ->
43- assert .isNull actual
43+ it ' handles invalid CoffeeScript data' , ->
44+ path = " #{ __dirname } /../../fixture/invalid/coffee.coffee"
4445
45- it ' handles file system errors' , ->
46- path = " #{ __dirname } /../../fixture/invalid/nonexistent.js"
46+ return @subject .handle path
47+ .catch (actual) ->
48+ assert .instanceOf actual, SyntaxError
4749
48- return @subject .handle path
49- .catch (actual) ->
50- assert .instanceOf actual, Error
50+ it ' handles file system errors' , ->
51+ path = " #{ __dirname } /../../fixture/invalid/nonexistent.js"
52+
53+ return @subject .handle path
54+ .catch (actual) ->
55+ assert .instanceOf actual, Error
0 commit comments