-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathViewModelTest.js
More file actions
19 lines (16 loc) · 913 Bytes
/
ViewModelTest.js
File metadata and controls
19 lines (16 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var Database = JQB.Schema.Database;
var Table = JQB.Schema.Table;
describe("ViewModelSql", function () {
var csv = "accounts,id,char,PRI\n" + "accounts,name,varchar,\n" + "users,id,char,PRI\n" + "users,account_id,char,\n" + "users,name,varchar,\n";
it("should build a simple one-table query", function () {
var vm = new JQB.ViewModel({ schemaCsv: csv });
vm.addTableToQuery(vm.schema().table('accounts'));
expect(vm.sql()).toBe("select t0.`name`\nfrom `accounts` t0");
});
it("should build a simple two-table join", function () {
var vm = new JQB.ViewModel({ schemaCsv: csv });
vm.addTableToQuery(vm.schema().table('accounts'));
vm.addTableToQuery(vm.schema().table('users'));
expect(vm.sql()).toBe("select t0.`name`, t1.`name`\n" + "from `accounts` t0\n" + "join `users` t1 on t1.`account_id` = t0.`id`");
});
});