5ee1bd7556fdd1ab80f8c71f621b92b147f8c4f0
[platform/framework/web/crosswalk-tizen.git] /
1 //jshint node:true
2 /*global describe, it*/
3 "use strict";
4
5 var expect = require('chai').expect;
6 var esformatter = require('../lib/esformatter');
7
8 var input = 'var foo = bar;\nfunction bar(dolor, amet) {\n  return dolor + amet;\n}';
9 var output1 = '\n// ---- esformatter-pipe-test-1 ---\n';
10 var output2 = '\n// ---- esformatter-pipe-test-2 ---\n';
11
12 describe('pipe', function() {
13
14   it('should call piped commands', function() {
15     var out = esformatter.format(input, {
16       pipe: {
17         before: [
18           'esformatter-pipe-test-1',
19         ],
20         after: [
21           'esformatter-pipe-test-2'
22         ]
23       }
24     });
25     expect(out).to.eql(input + output1 + output2);
26   });
27
28   it('should call piped commands in order', function() {
29     var out = esformatter.format(input, {
30       pipe: {
31         after: [
32           'esformatter-pipe-test-2',
33           'esformatter-pipe-test-1'
34         ]
35       }
36     });
37     expect(out).to.eql(input + output2 + output1);
38   });
39
40   it('should throw error if command not found', function() {
41     expect(function() {
42       esformatter.format(input, {
43         pipe: {
44           before: [
45             'esformatter-fake-pipe-command'
46           ]
47         }
48       });
49     }).to.throw();
50   });
51
52 });