Skip to content

Commit

Permalink
add test cases of sqlparser.js
Browse files Browse the repository at this point in the history
  • Loading branch information
XadillaX committed Oct 23, 2015
1 parent 5de52a4 commit 3f07a17
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion test/sqlparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.