sequelize.test.js
2.38 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
'use strict';
/* jshint -W030 */
var chai = require('chai')
, sinon = require('sinon')
, expect = chai.expect
, _ = require('lodash')
, Sequelize = require(__dirname + '/../../index');
describe('sequelize constructor', function () {
it('should support database, username, password, options', function () {
var database = Math.random().toString()
, username = Math.random().toString()
, password = Math.random().toString()
, host = Math.random().toString()
, port = Math.random().toString();
var sequelize = new Sequelize(database, username, password, {
host: host,
port: port
});
expect(sequelize.config.database).to.equal(database);
expect(sequelize.config.username).to.equal(username);
expect(sequelize.config.password).to.equal(password);
expect(sequelize.config.host).to.equal(host);
expect(sequelize.config.port).to.equal(port);
});
it('should connection uri, options', function () {
var dialect = 'postgres'
, database = Math.ceil(Math.random() * 9999).toString()
, username = Math.ceil(Math.random() * 9999).toString()
, password = Math.ceil(Math.random() * 9999).toString()
, host = Math.ceil(Math.random() * 9999).toString()
, port = Math.ceil(Math.random() * 9999).toString();
var uri = dialect + '://' + username + ':' + password + '@' + host + ':' + port + '/' + database;
var sequelize = new Sequelize(uri);
expect(sequelize.config.database).to.equal(database);
expect(sequelize.config.username).to.equal(username);
expect(sequelize.config.password).to.equal(password);
expect(sequelize.config.host).to.equal(host);
expect(sequelize.config.port).to.equal(port);
});
it('should support options', function () {
var database = Math.random().toString()
, username = Math.random().toString()
, password = Math.random().toString()
, host = Math.random().toString()
, port = Math.random().toString();
var sequelize = new Sequelize({
host: host,
port: port,
database: database,
username: username,
password: password
});
expect(sequelize.config.database).to.equal(database);
expect(sequelize.config.username).to.equal(username);
expect(sequelize.config.password).to.equal(password);
expect(sequelize.config.host).to.equal(host);
expect(sequelize.config.port).to.equal(port);
});
});