Permalink
Browse files

add test cases of sqlparser.js

  • Loading branch information...
XadillaX committed Oct 23, 2015
1 parent 5de52a4 commit 3f07a179d9592c3c2de3a666ee49684a933e4c12
Showing with 30 additions and 1 deletion.
  1. +30 −1 test/sqlparser.js
@@ -75,12 +75,41 @@ describe("Some SQL Parser", function() {
});

it("should be SELECT a FROM b WHERE `c", function() {
var sql = "SELECT aa FROM b WHERE `cc";
var sql = "SELECT aa FROM b WHERE `c";
var answer = parser.sqlNameToColumn(sql, {
aa: "a",
cc: "c"
});
answer.should.be.eql("SELECT a FROM b WHERE `c");
});

it("should be SELECT a FROM b WHERE c\"1\"", function() {
var sql = "SELECT aa FROM b WHERE cc\"1\"";
var answer = parser.sqlNameToColumn(sql, {
aa: "a",
cc: "c"
});
answer.should.be.eql("SELECT a FROM b WHERE c\"1\"");
});

it("should be SELECT a, d FROM b WHERE `c`", function() {
var sql = "SELECT aa, dd FROM b WHERE `c`";
var answer = parser.sqlNameToColumn(sql, {
aa: "a",
dd: "d"
});
answer.should.be.eql("SELECT a, d FROM b WHERE `c`");
});

it("should be SELECT a FROM b WHERE calc(`d`) = `e`", function() {
var sql = "SELECT aa FROM b WHERE calc(`dd`) = `ee`";
var answer = parser.sqlNameToColumn(sql, {
aa: "a",
dd: "d",
ee: "e"
});
answer.should.be.eql("SELECT a FROM b WHERE calc(`d`) = `e`");
});

});
});

0 comments on commit 3f07a17

Please sign in to comment.