Skip to content

Commit

Permalink
Fix the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sdepold committed Apr 11, 2014
1 parent b533451 commit 949208a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions test/sequelize/log.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ chai.config.includeStack = true

describe(Support.getTestDialectTeaser("Sequelize"), function () {
describe('log', function() {
beforeEach(function() {
this.spy = sinon.spy(console, 'log')
})

afterEach(function() {
console.log.restore()
})

describe("with disabled logging", function() {
beforeEach(function() {
this.sequelize = new Support.Sequelize('db', 'user', 'pw', { logging: false })
this.spy = sinon.spy(console.log)
})

it("does not call the log method of the logger", function() {
Expand All @@ -27,32 +34,31 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
describe('with default logging options', function() {
beforeEach(function() {
this.sequelize = new Support.Sequelize('db', 'user', 'pw')
this.spy = sinon.spy(console.log)
})

describe("called with no arguments", function() {
it('calls the log method', function() {
this.sequelize.log()
expect(this.spy.calledOnce).to.be.false
expect(this.spy.calledOnce).to.be.true
})

it('logs an empty string as info event', function() {
this.sequelize.log()
expect(this.spy.withArgs('').calledOnce).to.be.false
expect(this.spy.calledOnce).to.be.true
})
})

describe("called with one argument", function() {
it('logs the passed string as info event', function() {
this.sequelize.log('my message')
expect(this.spy.withArgs('my message').calledOnce).to.be.false
expect(this.spy.withArgs('my message').calledOnce).to.be.true
})
})

describe("called with more than two arguments", function() {
it("passes the arguments to the logger", function() {
this.sequelize.log('error', 'my message', 1, { a: 1 })
expect(this.spy.withArgs('error', 'my message', 1, { a: 1 }).calledOnce).to.be.false
expect(this.spy.withArgs('error', 'my message', 1, { a: 1 }).calledOnce).to.be.true
})
})
})
Expand Down

0 comments on commit 949208a

Please sign in to comment.