-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathViewModelTest.ts
More file actions
34 lines (27 loc) · 1 KB
/
ViewModelTest.ts
File metadata and controls
34 lines (27 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/// <reference path="Scripts/typings/jasmine/jasmine.d.ts" />
/// <reference path="ViewModel.ts" />
/// <chutzpah_reference path="./Scripts/knockout-2.3.0.js" />
var Database = JQB.Schema.Database;
var Table = JQB.Schema.Table;
describe("ViewModelSql", () => {
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", () => {
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", () => {
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`");
});
});