(Type, value, options)
| 58 | }); |
| 59 | |
| 60 | const testSuccess = async function(Type, value, options) { |
| 61 | const parse = Type.constructor.parse = sinon.spy(value => { |
| 62 | return value; |
| 63 | }); |
| 64 | |
| 65 | const stringify = Type.constructor.prototype.stringify = sinon.spy(function() { |
| 66 | return Sequelize.ABSTRACT.prototype.stringify.apply(this, arguments); |
| 67 | }); |
| 68 | let bindParam; |
| 69 | if (options && options.useBindParam) { |
| 70 | bindParam = Type.constructor.prototype.bindParam = sinon.spy(function() { |
| 71 | return Sequelize.ABSTRACT.prototype.bindParam.apply(this, arguments); |
| 72 | }); |
| 73 | } |
| 74 | |
| 75 | const User = current.define('user', { |
| 76 | field: Type |
| 77 | }, { |
| 78 | timestamps: false |
| 79 | }); |
| 80 | |
| 81 | await current.sync({ force: true }); |
| 82 | |
| 83 | current.refreshTypes(); |
| 84 | |
| 85 | await User.create({ |
| 86 | field: value |
| 87 | }); |
| 88 | |
| 89 | await User.findAll(); |
| 90 | expect(parse).to.have.been.called; |
| 91 | if (options && options.useBindParam) { |
| 92 | expect(bindParam).to.have.been.called; |
| 93 | } else { |
| 94 | expect(stringify).to.have.been.called; |
| 95 | } |
| 96 | |
| 97 | delete Type.constructor.parse; |
| 98 | delete Type.constructor.prototype.stringify; |
| 99 | if (options && options.useBindParam) { |
| 100 | delete Type.constructor.prototype.bindParam; |
| 101 | } |
| 102 | }; |
| 103 | |
| 104 | const testFailure = function(Type) { |
| 105 | Type.constructor.parse = _.noop(); |
no test coverage detected
searching dependent graphs…