123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- var assert = require('assert');
- var _ = require('@sailshq/lodash');
- var Adapter = require('../../../lib/adapter');
- var Support = require('../../support/bootstrap');
- describe('Unit Tests ::', function() {
- describe('Define', function() {
- // Test Setup
- before(function(done) {
- Support.registerConnection(['test_define'], done);
- });
- after(function(done) {
- Support.Teardown('test_define', done);
- });
- // Attributes for the test table
- var definition = {
- id: {
- columnType: 'serial',
- autoIncrement: true
- },
- name: {
- columnType: 'text',
- notNull: true
- },
- email: {
- columnType: 'text'
- },
- title: {
- columnType: 'text'
- },
- phone: {
- columnType: 'text'
- },
- type: {
- columnType: 'text'
- },
- favoriteFruit: {
- columnType: 'text'
- },
- age: {
- columnType: 'integer'
- }
- };
- it('should create a table in the database', function(done) {
- Adapter.define('test', 'test_define', definition, function(err) {
- if (err) {
- return done(err);
- }
- Adapter.describe('test', 'test_define', function(err, result) {
- if (err) {
- return done(err);
- }
- assert(_.isPlainObject(result));
- assert.equal(_.keys(result).length, 8);
- assert(result.id);
- assert(result.name);
- assert(result.email);
- assert(result.title);
- assert(result.phone);
- assert(result.type);
- assert(result.favoriteFruit);
- assert(result.age);
- return done();
- });
- });
- });
- });
- });
|