UNPKG

1.29 kBJavaScriptView Raw
1"use strict";
2/*jshint -W079*/
3var chai = require("chai"),
4 expect = chai.expect,
5 ncp = require('ncp').ncp,
6 grunt = require("grunt"),
7 JsBeautifierTask = require("../lib/jsbeautifier"),
8 createMockTask = require("./mockTask");
9
10chai.use(require('chai-fs'));
11/*jshint -W030*/
12describe("JsBeautifier: Javascript options", function() {
13 var mockTask;
14
15 beforeEach(function(done) {
16 grunt.file.mkdir("tmp/common");
17 ncp("test/fixtures/common", "tmp/common", done);
18 });
19
20 afterEach(function() {
21 mockTask = null;
22 grunt.file.delete("tmp");
23 });
24
25 function assertBeautifiedFile() {
26 var actual = "tmp/common/not-been-beautified.js",
27 expected = grunt.file.read("tmp/common/no-newline-beautified.js");
28 expect(actual).to.have.content(expected, "should beautify js without newline");
29 }
30
31 it("Verify beautification with no new line for javascript file", function(done) {
32 var task;
33 mockTask = createMockTask({
34 js: {
35 endWithNewline: false
36 }
37 }, ["tmp/common/not-been-beautified.js"], function() {
38 assertBeautifiedFile();
39 done();
40 });
41
42 task = new JsBeautifierTask(mockTask);
43 task.run();
44 });
45});