不要怂,就是干,撸起袖子干!

Commit 12a12fc2 by Mick Hansen

Merge pull request #3868 from mdarveau/master

also shim static collection methods for CLS transaction carry over.
2 parents c63d2540 049c58f4
Showing with 48 additions and 0 deletions
...@@ -32,6 +32,10 @@ shimCLS(Promise.prototype, 'error', [0]); ...@@ -32,6 +32,10 @@ shimCLS(Promise.prototype, 'error', [0]);
shimCLS(Promise.prototype, 'finally', [0]); shimCLS(Promise.prototype, 'finally', [0]);
// Collections // Collections
shimCLS(Promise, 'map', [1]);
shimCLS(Promise, 'reduce', [1]);
shimCLS(Promise, 'filter', [1]);
shimCLS(Promise, 'each', [1]);
shimCLS(Promise.prototype, 'map', [0]); shimCLS(Promise.prototype, 'map', [0]);
shimCLS(Promise.prototype, 'reduce', [0]); shimCLS(Promise.prototype, 'reduce', [0]);
shimCLS(Promise.prototype, 'filter', [0]); shimCLS(Promise.prototype, 'filter', [0]);
......
...@@ -240,6 +240,17 @@ if (current.dialect.supports.transactions) { ...@@ -240,6 +240,17 @@ if (current.dialect.supports.transactions) {
}); });
}); });
it('static map', function () {
var self = this;
return this.sequelize.transaction(function () {
var tid = self.ns.get('transaction').id;
return self.sequelize.Promise.map(self.User.findAll(), function () {
expect(self.ns.get('transaction').id).to.be.ok;
expect(self.ns.get('transaction').id).to.equal(tid);
});
});
});
it('reduce', function () { it('reduce', function () {
var self = this; var self = this;
return this.sequelize.transaction(function () { return this.sequelize.transaction(function () {
...@@ -251,6 +262,17 @@ if (current.dialect.supports.transactions) { ...@@ -251,6 +262,17 @@ if (current.dialect.supports.transactions) {
}); });
}); });
it('static reduce', function () {
var self = this;
return this.sequelize.transaction(function () {
var tid = self.ns.get('transaction').id;
return self.sequelize.Promise.reduce(self.User.findAll(), function () {
expect(self.ns.get('transaction').id).to.be.ok;
expect(self.ns.get('transaction').id).to.equal(tid);
});
});
});
it('filter', function () { it('filter', function () {
var self = this; var self = this;
return this.sequelize.transaction(function () { return this.sequelize.transaction(function () {
...@@ -262,6 +284,17 @@ if (current.dialect.supports.transactions) { ...@@ -262,6 +284,17 @@ if (current.dialect.supports.transactions) {
}); });
}); });
it('static filter', function () {
var self = this;
return this.sequelize.transaction(function () {
var tid = self.ns.get('transaction').id;
return self.sequelize.Promise.filter(self.User.findAll(), function () {
expect(self.ns.get('transaction').id).to.be.ok;
expect(self.ns.get('transaction').id).to.equal(tid);
});
});
});
it('each', function () { it('each', function () {
var self = this; var self = this;
return this.sequelize.transaction(function () { return this.sequelize.transaction(function () {
...@@ -273,6 +306,17 @@ if (current.dialect.supports.transactions) { ...@@ -273,6 +306,17 @@ if (current.dialect.supports.transactions) {
}); });
}); });
it('static each', function () {
var self = this;
return this.sequelize.transaction(function () {
var tid = self.ns.get('transaction').id;
return self.sequelize.Promise.each(self.User.findAll(), function () {
expect(self.ns.get('transaction').id).to.be.ok;
expect(self.ns.get('transaction').id).to.equal(tid);
});
});
});
it('tap', function () { it('tap', function () {
var self = this; var self = this;
return this.sequelize.transaction(function () { return this.sequelize.transaction(function () {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!