MCPcopy
hub / github.com/sequelize/sequelize / testSuccess

Function testSuccess

test/integration/data-types.test.js:60–102  ·  view source on GitHub ↗
(Type, value, options)

Source from the content-addressed store, hash-verified

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();

Callers 1

data-types.test.jsFile · 0.85

Calls 5

defineMethod · 0.80
refreshTypesMethod · 0.80
findAllMethod · 0.80
syncMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…