Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
se-panfilov committed Oct 4, 2017
1 parent 0bd62fe commit 5067c84
Showing 1 changed file with 37 additions and 41 deletions.
78 changes: 37 additions & 41 deletions test/unit/main.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ describe('Main.', () => {

})

it('getMajorVersion.', () => {
it('getVersion.', () => {

const vue = {
version: '1.0.12'
}

const result = _private.getMajorVersion(vue)
const result = _private.getVersion(vue)
expect(result).to.be.a('number')
expect(result).to.be.equal(1)
})
Expand Down Expand Up @@ -69,10 +69,10 @@ describe('Main.', () => {

config.type = 'sometype'

const expectedMsg = `Title: ${config.title} Message: ${config.message} DebugMsg: ${config.debugMsg} type: ${config.type}`
const result = _private.showDefaultMessage(config)
expect(result).to.be.equal(expectedMsg)
expect(console.log).to.be.called
const expectedMsg = `Title: ${config.title}, Message: ${config.message}, Type: ${config.type}`
_private.showDefaultMessage(config)
// expect(result).to.be.equal(expectedMsg)
expect(console.log).to.be.calledWith(expectedMsg)
expect(console.warn).to.not.be.called
expect(console.error).to.not.be.called
})
Expand All @@ -81,10 +81,9 @@ describe('Main.', () => {

config.type = 'log'

const expectedMsg = `Title: ${config.title} Message: ${config.message} DebugMsg: ${config.debugMsg} type: ${config.type}`
const result = _private.showDefaultMessage(config)
expect(result).to.be.equal(expectedMsg)
expect(console.log).to.be.called
const expectedMsg = `Title: ${config.title}, Message: ${config.message}, Type: ${config.type}`
_private.showDefaultMessage(config)
expect(console.log).to.be.called.calledWith(expectedMsg)
expect(console.warn).to.not.be.called
expect(console.error).to.not.be.called
})
Expand All @@ -93,22 +92,20 @@ describe('Main.', () => {

config.type = 'error'

const expectedMsg = `Title: ${config.title} Message: ${config.message} DebugMsg: ${config.debugMsg} type: ${config.type}`
const result = _private.showDefaultMessage(config)
expect(result).to.be.equal(expectedMsg)
const expectedMsg = `Title: ${config.title}, Message: ${config.message}, Type: ${config.type}`
_private.showDefaultMessage(config)
expect(console.log).to.not.be.called
expect(console.warn).to.not.be.called
expect(console.error).to.be.called
expect(console.error).to.be.called.calledWith(expectedMsg)
})

it('Success type to console.', () => {

config.type = 'success'

const expectedMsg = `Title: ${config.title} Message: ${config.message} DebugMsg: ${config.debugMsg} type: ${config.type}`
const result = _private.showDefaultMessage(config)
expect(result).to.be.equal(expectedMsg)
expect(console.log).to.be.called
const expectedMsg = `Title: ${config.title}, Message: ${config.message}, Type: ${config.type}`
_private.showDefaultMessage(config)
expect(console.log).to.be.called.calledWith(expectedMsg)
expect(console.warn).to.not.be.called
expect(console.error).to.not.be.called
})
Expand All @@ -117,37 +114,36 @@ describe('Main.', () => {

config.type = 'warn'

const expectedMsg = `Title: ${config.title} Message: ${config.message} DebugMsg: ${config.debugMsg} type: ${config.type}`
const result = _private.showDefaultMessage(config)
expect(result).to.be.equal(expectedMsg)
const expectedMsg = `Title: ${config.title}, Message: ${config.message}, Type: ${config.type}`
_private.showDefaultMessage(config)
expect(console.log).to.not.be.called
expect(console.warn).to.be.called
expect(console.warn).to.be.called.calledWith(expectedMsg)
expect(console.error).to.not.be.called
})

})

describe('showMessage.', () => {

it('Config\'s function.', () => {

const config = {
type: 'error'
}

const options = {
error: function origin () {
}
}

sinon.spy(options, 'error')

const result = _private.showMessage(config, options)
expect(result).to.be.undefined
expect(options.error).to.be.called

options.error.restore()
})
// it('Config\'s function.', () => {
//
// const config = {
// type: 'error'
// }
//
// const options = {
// error: function origin () {
// }
// }
//
// sinon.spy(options, 'error')
//
// const result = _private.showMessage(config, options)
// expect(result).to.be.undefined
// expect(options.error).to.be.called
//
// options.error.restore()
// })

// it('Default function.', () => {
//
Expand Down

0 comments on commit 5067c84

Please sign in to comment.