forked from brianc/node-sql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable-tests.js
More file actions
45 lines (36 loc) · 1.01 KB
/
Copy pathtable-tests.js
File metadata and controls
45 lines (36 loc) · 1.01 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
35
36
37
38
39
40
41
42
43
44
45
'use strict';
var test = require('tap').test;
var Table = require(__dirname + '/../lib/table');
var Column = require(__dirname + '/../lib/column');
test('table', function(t) {
var table = new Table({
name: 'bang'
});
t.equal(table.getName(), 'bang');
t.equal(table.columns.length, 0);
var col = new Column({
table: table,
name: 'boom'
});
t.equal(col.name, 'boom');
t.equal(col.table.getName(), 'bang');
table.addColumn(col);
t.equal(table.columns.length, 1);
t.equal(table.boom, col);
console.log('table creates query node');
var sel = table.select(table.boom);
t.equal(sel.type, 'QUERY');
console.log('table can be defined');
var user = Table.define({
name: 'user',
columns: ['id', 'name']
});
t.equal(user.getName(), 'user');
t.equal(user.columns.length, 2);
t.equal(user.columns[0].name, 'id');
t.equal(user.columns[1].name, 'name');
t.equal(user.columns[0].name, user.id.name);
t.equal(user.id.table, user);
t.equal(user.name.table, user);
t.end();
});