mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
re-run checks
This commit is contained in:
@@ -42,7 +42,6 @@ EVp.withValue = function (value, func) {
|
||||
} finally {
|
||||
currentValues[this.slot] = saved;
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
@@ -49,22 +49,20 @@ class EnvironmentVariableAsync {
|
||||
*/
|
||||
withValue(value, func, options = {}) {
|
||||
const self = this;
|
||||
const slotCall = self.slot;
|
||||
const dynamics = Object.assign(
|
||||
{},
|
||||
Meteor._getValueFromAslStore(UPPER_CALL_DYNAMICS_KEY_NAME) || {}
|
||||
);
|
||||
|
||||
if (slotCall) {
|
||||
dynamics[slotCall] = value;
|
||||
}
|
||||
|
||||
const slotCall = Meteor._getValueFromAslStore(SLOT_CALL_KEY);
|
||||
const dynamics =
|
||||
Meteor._getValueFromAslStore(UPPER_CALL_DYNAMICS_KEY_NAME) || {};
|
||||
dynamics[slotCall] = Meteor._getValueFromAslStore(CURRENT_VALUE_KEY_NAME);
|
||||
self.upperCallDynamics = dynamics;
|
||||
return Meteor._runAsync(
|
||||
async function () {
|
||||
let ret;
|
||||
try {
|
||||
Meteor._updateAslStore(
|
||||
UPPER_CALL_DYNAMICS_KEY_NAME,
|
||||
this.upperCallDynamics,
|
||||
);
|
||||
Meteor._updateAslStore(CURRENT_VALUE_KEY_NAME, value);
|
||||
Meteor._updateAslStore(UPPER_CALL_DYNAMICS_KEY_NAME, dynamics);
|
||||
ret = await func();
|
||||
} finally {
|
||||
Meteor._updateAslStore(CURRENT_VALUE_KEY_NAME, undefined);
|
||||
@@ -82,7 +80,7 @@ class EnvironmentVariableAsync {
|
||||
[SLOT_CALL_KEY]: this.slot,
|
||||
},
|
||||
options,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,52 +16,27 @@ Tinytest.add("environment - dynamic variables", function (test) {
|
||||
test.equal(CurrentFoo.get(), undefined);
|
||||
});
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Tinytest.addAsync(
|
||||
"environment - dynamic variables with two context (server)",
|
||||
async function (test) {
|
||||
const context1 = new Meteor.EnvironmentVariable();
|
||||
const context2 = new Meteor.EnvironmentVariable();
|
||||
Tinytest.addAsync(
|
||||
"environment - dynamic variables with two context",
|
||||
async function (test) {
|
||||
const context1 = new Meteor.EnvironmentVariable();
|
||||
const context2 = new Meteor.EnvironmentVariable();
|
||||
|
||||
return context1.withValue(42, async () => {
|
||||
test.equal(context2.get(), undefined);
|
||||
await context2.withValue(1, async () => {
|
||||
await context2.withValue(2, async () => {
|
||||
test.equal(context2.get(), 2);
|
||||
});
|
||||
test.equal(context1.get(), 42);
|
||||
test.equal(context2.get(), 1);
|
||||
await context1.withValue(42, async () => {
|
||||
test.equal(context2.get(), undefined);
|
||||
await context2.withValue(1, async () => {
|
||||
await context2.withValue(2, async () => {
|
||||
test.equal(context2.get(), 2);
|
||||
});
|
||||
test.equal(context1.get(), 42);
|
||||
test.equal(context2.get(), undefined);
|
||||
test.equal(context2.get(), 1);
|
||||
});
|
||||
}
|
||||
);
|
||||
} else {
|
||||
// Basically the same test as the server one, but without async/await
|
||||
// as we don't handle async on the client in this case
|
||||
// due to the idea that we need to keep new EcmaScript features doesn't compile in older browsers
|
||||
Tinytest.add(
|
||||
"environment - dynamic variables with two context (client)",
|
||||
function (test) {
|
||||
const context1 = new Meteor.EnvironmentVariable();
|
||||
const context2 = new Meteor.EnvironmentVariable();
|
||||
test.equal(context1.get(), 42);
|
||||
test.equal(context2.get(), undefined);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
context1.withValue(42, () => {
|
||||
test.equal(context2.get(), undefined);
|
||||
context2.withValue(1, () => {
|
||||
context2.withValue(2, () => {
|
||||
test.equal(context2.get(), 2);
|
||||
});
|
||||
test.equal(context1.get(), 42);
|
||||
test.equal(context2.get(), 1);
|
||||
});
|
||||
test.equal(context1.get(), 42);
|
||||
test.equal(context2.get(), undefined);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
Tinytest.addAsync("environment - bindEnvironment", async function (test) {
|
||||
var raised_f;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user