knex/test/tape/knex.js

59 lines
1.3 KiB
JavaScript
Raw Normal View History

2015-05-01 14:55:53 -04:00
'use strict';
var knex = require('../../lib/index');
var test = require('tape')
test('it should parse the connection string', function(t) {
t.plan(1)
var knexObj = knex({
client: 'mysql',
connection: "mysql://user:password@example.com/dbname"
})
t.deepEqual(knexObj.client.config.connection, {
database: 'dbname',
host: 'example.com',
password: 'password',
user: 'user'
})
knexObj.destroy()
})
test('it should allow to use proprietary dialect', function(t) {
t.plan(2)
var Client = require('../../lib/dialects/mysql')
var knexObj = knex({
client: Client,
database: 'dbname',
host: 'example.com',
password: 'password',
user: 'user'
})
t.ok(knexObj.client instanceof Client)
t.deepEqual(knexObj.client.config.connection, {
client: Client,
database: 'dbname',
host: 'example.com',
password: 'password',
user: 'user'
})
knexObj.destroy()
})
test('it should use knex suppoted dialect', function(t) {
t.plan(1)
var knexObj = knex({
client: 'postgres',
database: 'dbname',
host: 'example.com',
password: 'password',
user: 'user'
})
t.deepEqual(knexObj.client.config.connection, {
client: 'postgres',
database: 'dbname',
host: 'example.com',
password: 'password',
user: 'user'
})
knexObj.destroy()
})