Skip to content

Commit

Permalink
Revert use of async/await due to lack of build/serve support.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Feb 9, 2018
1 parent dea9080 commit d4a7a45
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2017
"ecmaVersion": 6
},
"rules": {
"no-console": "off",
Expand Down
77 changes: 43 additions & 34 deletions test/unit/path-effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
document.body.removeChild(el);
});

async function verifyObserverOutput(nestingLevel, nested) {
function verifyObserverOutput(nestingLevel, nested, done) {
assert.equal(el.computed, '[' + nested.obj.value + ']');
assert.equal(el.nestedChanged.callCount, nestingLevel == 0 ? 1 : 0);
if (nestingLevel == 0) {
Expand Down Expand Up @@ -105,9 +105,12 @@
assert.equal(el.$.forward.objSubpathChanged.firstCall.args[0].value, nested.obj);
assert.equal(el.$.forward.$.compose.objSubpathChanged.firstCall.args[0].path, 'obj');
assert.equal(el.$.forward.$.compose.objSubpathChanged.firstCall.args[0].value, nested.obj);
await Promise.resolve(); // x-pe uses async PropertiesChanged
assert.equal(el.$.pe._propertiesChanged.callCount, 1);
assert.equal(el.$.pe._propertiesChanged.firstCall.args[1].obj, nested.obj);
// x-pe uses async PropertiesChanged
Promise.resolve().then(() => {
assert.equal(el.$.pe._propertiesChanged.callCount, 1);
assert.equal(el.$.pe._propertiesChanged.firstCall.args[1].obj, nested.obj);
done();
});
break;
case 1:
assert.equal(el.nestedSubpathChanged.firstCall.args[0].path, 'nested.obj');
Expand All @@ -120,9 +123,12 @@
assert.equal(el.$.forward.objSubpathChanged.firstCall.args[0].value, nested.obj);
assert.equal(el.$.forward.$.compose.objSubpathChanged.firstCall.args[0].path, 'obj');
assert.equal(el.$.forward.$.compose.objSubpathChanged.firstCall.args[0].value, nested.obj);
await Promise.resolve(); // x-pe uses async PropertiesChanged
assert.equal(el.$.pe._propertiesChanged.callCount, 1);
assert.equal(el.$.pe._propertiesChanged.firstCall.args[1].obj, nested.obj);
// x-pe uses async PropertiesChanged
Promise.resolve().then(() => {
assert.equal(el.$.pe._propertiesChanged.callCount, 1);
assert.equal(el.$.pe._propertiesChanged.firstCall.args[1].obj, nested.obj);
done();
});
break;
case 2:
assert.equal(el.nestedSubpathChanged.firstCall.args[0].path, 'nested.obj.value');
Expand All @@ -135,27 +141,30 @@
assert.equal(el.$.forward.objSubpathChanged.firstCall.args[0].value, 42);
assert.equal(el.$.forward.$.compose.objSubpathChanged.firstCall.args[0].path, 'obj.value');
assert.equal(el.$.forward.$.compose.objSubpathChanged.firstCall.args[0].value, 42);
await Promise.resolve(); // x-pe uses async PropertiesChanged
// Note the PropertiesMixin element only sees a deep set to 'nested.obj.value'
// because it overrides _shouldPropertyChange to allow object re-sets through
assert.equal(el.$.pe._propertiesChanged.callCount, 1);
assert.equal(el.$.pe._propertiesChanged.firstCall.args[1].obj, nested.obj);
// x-pe uses async PropertiesChanged
Promise.resolve().then(() => {
// Note the PropertiesMixin element only sees a deep set to 'nested.obj.value'
// because it overrides _shouldPropertyChange to allow object re-sets through
assert.equal(el.$.pe._propertiesChanged.callCount, 1);
assert.equal(el.$.pe._propertiesChanged.firstCall.args[1].obj, nested.obj);
done();
});
break;
}
}

test('downward data flow', async function() {
test('downward data flow', function(done) {
// Do the thing
el.nested = {
obj: {
value: 42
}
};
// Verify
await verifyObserverOutput(0, el.nested);
verifyObserverOutput(0, el.nested, done);
});

test('notification from basic element property change', async function() {
test('notification from basic element property change', function(done) {
// Setup
el.nested = {
obj: {
Expand All @@ -166,10 +175,10 @@
// Do the thing
el.$.basic.notifyingValue = 42;
// Verify
await verifyObserverOutput(2, el.nested);
verifyObserverOutput(2, el.nested, done);
});

test('notification from composed element property change', async function() {
test('notification from composed element property change', function(done) {
// Setup
el.nested = {
obj: {
Expand All @@ -180,10 +189,10 @@
// Do the thing
el.$.compose.$.basic1.notifyingValue = 42;
// Verify
await verifyObserverOutput(2, el.nested);
verifyObserverOutput(2, el.nested, done);
});

test('notification from forward\'s composed element property change', async function() {
test('notification from forward\'s composed element property change', function(done) {
// Setup
el.nested = {
obj: {
Expand All @@ -194,10 +203,10 @@
// Do the thing
el.$.forward.$.compose.$.basic1.notifyingValue = 42;
// Verify
await verifyObserverOutput(2, el.nested);
verifyObserverOutput(2, el.nested, done);
});

test('notification from set in top element', async function() {
test('notification from set in top element', function(done) {
// Setup
el.nested = {
obj: {
Expand All @@ -208,10 +217,10 @@
// Do the thing
el.set('nested.obj.value', 42);
// Verify
await verifyObserverOutput(2, el.nested);
verifyObserverOutput(2, el.nested, done);
});

test('notification from set in composed element', async function() {
test('notification from set in composed element', function(done) {
// Setup
el.nested = {
obj: {
Expand All @@ -222,10 +231,10 @@
// Do the thing
el.$.compose.set('obj.value', 42);
// Verify
await verifyObserverOutput(2, el.nested);
verifyObserverOutput(2, el.nested, done);
});

test('notification from set in forward element', async function() {
test('notification from set in forward element', function(done) {
// Setup
el.nested = {
obj: {
Expand All @@ -236,10 +245,10 @@
// Do the thing
el.$.forward.set('obj.value', 42);
// Verify
await verifyObserverOutput(2, el.nested);
verifyObserverOutput(2, el.nested, done);
});

test('notification from set in forward\'s composed element', async function() {
test('notification from set in forward\'s composed element', function(done) {
// Setup
el.nested = {
obj: {
Expand All @@ -250,10 +259,10 @@
// Do the thing
el.$.forward.$.compose.set('obj.value', 42);
// Verify
await verifyObserverOutput(2, el.nested);
verifyObserverOutput(2, el.nested, done);
});

test('notification from object change in compose element', async function() {
test('notification from object change in compose element', function(done) {
// Setup
el.nested = {
obj: {
Expand All @@ -266,10 +275,10 @@
value: 42
};
// Verify
await verifyObserverOutput(1, el.nested);
verifyObserverOutput(1, el.nested, done);
});

test('notification from object change in forward element', async function() {
test('notification from object change in forward element', function(done) {
// Setup
el.nested = {
obj: {
Expand All @@ -282,10 +291,10 @@
value: 42
};
// Verify
await verifyObserverOutput(1, el.nested);
verifyObserverOutput(1, el.nested, done);
});

test('notification from object change in forward\'s compose element', async function() {
test('notification from object change in forward\'s compose element', function(done) {
// Setup
el.nested = {
obj: {
Expand All @@ -299,7 +308,7 @@
value: 42
};
// Verify
await verifyObserverOutput(1, el.nested);
verifyObserverOutput(1, el.nested, done);
});

test('cached paths get invalidated by object sets', function() {
Expand Down

0 comments on commit d4a7a45

Please sign in to comment.