Closed alexdrans closed 7 years ago
Hi
It could be interesting.
I have used other stuff from substack but never its own testing framework.
I can try to look how to integrate it when I found some times.
Many thank for your feedback
Regards
Awesome, good news.
Anything I can help with?
If you want to give me a pull request, this is a good idea :)
tape doesn't have explicit before, beforeEach, after or afterEach functions and so I got thinking about how to implement sequelize-mocking for tape.
I figured that I could expose the functions of the module to be used manually, like this.
I will take a look of your feedbacks
Thanks !
Had a chance to take a look?
Hi @alexdrans
I'm sorry, I have a lot of work at my job and few times at home
I have finished to look on some tasks on another project. I hope to look soon this point
Sorry
Regards
Hi
I start to work on it.
I think it should be:
/**
* Using SequelizeMocking with tape easily
*
* @module lib/sequelize-mocking-tape
* @exports sequelizeMochingTape
* @version 0.1.0
* @since 0.1.0
* @author Julien Roche
*/
'use strict';
// Imports
const test = require('tape');
const Sequelize = require('sequelize');
const _ = Sequelize.Utils._;
const SequelizeMocking = require('./sequelize-mocking');
/**
* @method
* @private
* @param {Test} test
* @param {Function} handler
* @returns {Function}
*/
function beforeEach(test, handler) {
return function (name, listener) {
test(name, function (assert) {
let _end = assert.end;
assert.end = function () {
assert.end = _end;
listener(assert);
};
handler(assert);
});
}
}
/**
* @method
* @private
* @param {Test} test
* @param {Function} handler
* @returns {Function}
*/
function afterEach(test, handler) {
return function (name, listener) {
test(name, function (assert) {
let _end = assert.end;
assert.end = function () {
assert.end = _end;
handler(assert);
};
listener(assert);
});
}
}
/**
* @name sequelizeMochingMocha
* @param {Sequelize} originalSequelize
* @param {string} [fixtureFilePath]
* @param {SequelizeMockingOptions} [options]
*/
module.exports = function (originalSequelize, fixtureFilePath, options) {
let mockedSequelize = null;
let newTest = null;
newTest = beforeEach(test, function (assert) {
let createFunc = _.partialRight(fixtureFilePath ? SequelizeMocking.createAndLoadFixtureFile : SequelizeMocking.create, options);
createFunc(originalSequelize, fixtureFilePath)
.then(function (sequelizeInstance) {
mockedSequelize = sequelizeInstance;
assert.end();
})
.catch(assert.end);
});
newTest = afterEach(newTest, function (assert) {
SequelizeMocking
.restore(mockedSequelize, options)
.then(function () {
assert.end();
})
.catch(assert.end);
});
return newTest;
};
I try to publish a feature branch with examples (maybe into the weekend)
Cheers
Bump @rochejul
Hi,
I write my tests using tape. Would it be straight forward enough to get this module working with it?