Monday 28 March 2016

Need Sequalize help, Testing, Jasmine.

Sooo i think it's best i just paste the code. It is returning an object, which has circular references (can't JSON.stringify easily). This means i cannot expect(result).tEqual(jsonObj) How would i do this??Test Code: var Sequelize = require("sequelize"); var DbConnection = require('./../../core/dbConnection'); var dbCon; describe("A DBConnection Object", function(){ beforeEach(function(){ dbCon = new DbConnection("","",""); }); it("will add a model to the connection",function(){ var model = { name: Sequelize.STRING, type: Sequelize.STRING }; dbCon.add('cheese',model); var result = dbCon.get('cheese'); console.log(result); expect(result).toEqual({ "name": Sequelize.STRING, "type": Sequelize.STRING }); }); });DBConnection:var Sequelize = require('sequelize');var DbConnection = function(databaseName, username, password, host){ //if host is defined, use that, else use localhost var hst = (host)? host: "localhost"; this._connection = new Sequelize(databaseName,username,password,{ dialect: 'mssql', host:hst }); this._state = "not ready"; this._models = {}; }; DbConnection.prototype = { get: function(modelName){ //get a model by the modelName return this._models[modelName]; }, add: function(modelName, model){ var newModel = this._connection.define(modelName,model); this._models[modelName] = newModel; //add a model to the array }, ...

Submitted March 28, 2016 at 08:11AM by ThomasSmWatson

No comments:

Post a Comment