if (typeof process !== "undefined") {
require("amd-loader");
}
define(function(require, exports, module) {
"use strict";
var assert = require("assert");
var EditSession = require("../edit_session").EditSession;
var beautify = require("./beautify");
var PHPMode = require("../mode/php").Mode;
// Execution ORDER: test.setUpSuite, setUp, testFn, tearDown, test.tearDownSuite
module.exports = {
timeout: 10000,
"test beautify first line empty": function(next) {
var s = new EditSession([
"",
"hello world"
], new PHPMode());
s.setUseSoftTabs(false);
beautify.beautify(s);
assert.equal(s.getValue(), "hello world");
next();
},
"test beautify block tag indentation": function(next) {
var s = new EditSession([
"
",
"
hello
",
"world"
], new PHPMode());
s.setUseSoftTabs(false);
beautify.beautify(s);
assert.equal(s.getValue(), "\n"
+ "\t
hello
\n"
+ "\tworld\n"
+ "");
next();
},
"test beautify block tag line breaks and indentation": function(next) {
var s = new EditSession([
""
], new PHPMode());
s.setUseSoftTabs(false);
beautify.beautify(s);
assert.equal(s.getValue(), "\n"
+ "\n"
+ "\t\n"
+ "\n"
+ "");
next();
},
"test beautify empty block tag": function(next) {
var s = new EditSession([
"\t"
], new PHPMode());
s.setUseSoftTabs(false);
beautify.beautify(s);
assert.equal(s.getValue(), "");
next();
},
"test beautify inline tag indentation": function(next) {
var s = new EditSession([
"",
"hello world",
"
"
], new PHPMode());
s.setUseSoftTabs(false);
beautify.beautify(s);
assert.equal(s.getValue(), "\n"
+ "\thello world\n"
+ "
");
next();
},
"test beautify multiline inline tag indentation": function(next) {
var s = new EditSession([
"",
"",
"hello world",
"",
"
"
], new PHPMode());
s.setUseSoftTabs(false);
beautify.beautify(s);
assert.equal(s.getValue(), "\n"
+ "\t\n"
+ "\t\thello world\n"
+ "\t\n"
+ "
");
next();
},
"test beautify singleton tag indentation": function(next) {
var s = new EditSession([
"",
"hello
",
"world",
"
"
], new PHPMode());
s.setUseSoftTabs(false);
beautify.beautify(s);
assert.equal(s.getValue(), "\n"
+ "\thello
\n"
+ "\tworld\n"
+ "
");
next();
},
"test beautify unknown singleton indentation": function(next) {
var s = new EditSession([
"",
"hello",
"world",
"
"
], new PHPMode());
s.setUseSoftTabs(false);
beautify.beautify(s);
assert.equal(s.getValue(), "\n"
+ "\thello\n"
+ "\tworld\n"
+ "
");
next();
},
"test beautify curly indentation": function(next) {
var s = new EditSession([
"",
"\n"
+ "",
"\t
",
""
], new PHPMode());
s.setUseSoftTabs(false);
beautify.beautify(s);
assert.equal(s.getValue(), "");
next();
},
"test beautify css": function(next) {
var s = new EditSession([
""
], new PHPMode());
s.setUseSoftTabs(false);
beautify.beautify(s);
assert.equal(s.getValue(), "");
next();
},
"test beautify comments": function(next) {
var s = new EditSession([
"\n",
""
], new PHPMode());
s.setUseSoftTabs(false);
beautify.beautify(s);
assert.equal(s.getValue(), "\n"
+ "");
next();
},
"test beautify js array of objects": function(next) {
var s = new EditSession([
""
], new PHPMode());
s.setUseSoftTabs(false);
beautify.beautify(s);
assert.equal(s.getValue(), "");
next();
},
"test beautify js object": function(next) {
var s = new EditSession([
''
], new PHPMode());
s.setUseSoftTabs(false);
beautify.beautify(s);
assert.equal(s.getValue(), "");
next();
}
};
});
if (typeof module !== "undefined" && module === require.main) {
require("asyncjs").test.testcase(module.exports).exec();
}