change behaviour of tests and browser testing/build
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
var generate = require("../lib/6to5/generator");
|
||||
var traverse = require("../lib/6to5/traverse");
|
||||
var assert = require("assert");
|
||||
var helper = require("./_helper");
|
||||
var util = require("../lib/6to5/util");
|
||||
var chai = require("chai");
|
||||
var fs = require("fs");
|
||||
var _ = require("lodash");
|
||||
|
||||
var fixturesLoc = __dirname + "/fixtures/generation";
|
||||
|
||||
suite("generation", function () {
|
||||
test("completeness", function () {
|
||||
_.each(traverse.VISITOR_KEYS, function (keys, type) {
|
||||
@@ -19,33 +17,19 @@ suite("generation", function () {
|
||||
assert.ok(traverse.VISITOR_KEYS[type], type + " should not exist");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
_.each(fs.readdirSync(fixturesLoc), function (suiteName) {
|
||||
if (suiteName[0] === ".") return;
|
||||
_.each(helper.get("generation"), function (testSuite) {
|
||||
suite("generation/" + testSuite.title, function () {
|
||||
_.each(testSuite.tests, function (task) {
|
||||
test(task.title, function () {
|
||||
var expect = task.expect;
|
||||
var actual = task.actual;
|
||||
|
||||
var suiteLoc = fixturesLoc + "/" + suiteName;
|
||||
var actualAst = util.parseNoProperties(actual.loc, actual.code);
|
||||
var actualCode = generate(actual, actualAst).code;
|
||||
|
||||
suite(suiteName, function () {
|
||||
_.each(fs.readdirSync(suiteLoc), function (testName) {
|
||||
if (testName[0] === ".") return;
|
||||
|
||||
var testLoc = suiteLoc + "/" + testName;
|
||||
|
||||
test(testName, function () {
|
||||
var expectedLoc = testLoc + "/expected.js";
|
||||
var actualLoc = testLoc + "/actual.js";
|
||||
|
||||
var expected = fs.readFileSync(expectedLoc, "utf8");
|
||||
var actual = fs.readFileSync(actualLoc, "utf8");
|
||||
|
||||
var actualAst = util.parseNoProperties(actualLoc, actual);
|
||||
actual = generate(actual, actualAst).code;
|
||||
actualAst = util.parseNoProperties(actualLoc, actual);
|
||||
|
||||
var expectedAst = util.parseNoProperties(expectedLoc, expected);
|
||||
|
||||
chai.expect(actualAst).to.deep.equal(expectedAst);
|
||||
});
|
||||
chai.expect(actualCode).to.equal(expect.code, actual.loc + " !== " + expect.loc);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user