bc6c28f1784f76dfb64704123919762080ced8c0
[platform/framework/web/crosswalk-tizen.git] /
1 //jshint node:true, eqnull:true
2 /*global describe, it, before*/
3 'use strict';
4
5 var esformatter = require('esformatter');
6 var fs = require('fs');
7 var quotes = require('../');
8 var expect = require('chai').expect;
9
10
11 describe('compare input/output', function() {
12
13   var input;
14
15   before(function() {
16     input = getFile('input.js');
17     esformatter.register(quotes);
18   });
19
20   describe('single quote', function() {
21     it('should convert to single quotes and normalize escapes', function() {
22       var output = esformatter.format(input, {
23         quotes: {
24           type: 'single'
25         }
26       });
27       expect(output).to.be.eql(getFile('output-single.js'));
28     });
29
30     it('should avoid escape', function() {
31       var output = esformatter.format(input, {
32         quotes: {
33           type: 'single',
34           avoidEscape: true
35         }
36       });
37       expect(output).to.be.eql(getFile('output-single-avoid.js'));
38     });
39   });
40
41   describe('double quote', function() {
42     it('should convert to double quotes and normalize escapes', function() {
43       var output = esformatter.format(input, {
44         quotes: {
45           type: 'double'
46         }
47       });
48       expect(output).to.be.eql(getFile('output-double.js'));
49     });
50
51     it('should avoid escape', function() {
52       var output = esformatter.format(input, {
53         quotes: {
54           type: 'double',
55           avoidEscape: true
56         }
57       });
58       expect(output).to.be.eql(getFile('output-double-avoid.js'));
59     });
60   });
61
62 });
63
64
65 function getFile(name) {
66   return fs.readFileSync('test/compare/' + name).toString();
67 }