diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-03-04 13:32:37 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-06-12 17:26:31 -0300 |
commit | 919fb164536151e04e61fde1f1b1bdb5beb3ef88 (patch) | |
tree | 7ed032d53c3e50c6c3b419318b19006d91c5bc85 /test | |
parent | b26a9c07501dd455d18be109d70f88443ef4dd2c (diff) |
data, test: withPropertyFromObject: 'internal' input
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/data/composite/data/withPropertyFromObject.js | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/test/unit/data/composite/data/withPropertyFromObject.js b/test/unit/data/composite/data/withPropertyFromObject.js index 50ee835c..912c924c 100644 --- a/test/unit/data/composite/data/withPropertyFromObject.js +++ b/test/unit/data/composite/data/withPropertyFromObject.js @@ -1,6 +1,7 @@ import t from 'tap'; import {quickCheckCompositeOutputs} from '#test-lib'; +import CacheableObject from '#cacheable-object'; import {compositeFrom, input} from '#composite'; import {exposeDependency} from '#composite/control-flow'; import {withPropertyFromObject} from '#composite/data'; @@ -43,6 +44,89 @@ t.test(`withPropertyFromObject: basic behavior`, t => { }), null); }); +t.test(`withPropertyFromObject: "internal" input`, t => { + t.plan(7); + + const composite = compositeFrom({ + compose: false, + + steps: [ + withPropertyFromObject({ + object: 'object', + property: 'property', + internal: 'internal', + }), + + exposeDependency({dependency: '#value'}), + ], + }); + + const thing = new (class extends CacheableObject { + static [CacheableObject.propertyDescriptors] = { + foo: { + flags: {update: true, expose: false}, + }, + + bar: { + flags: {update: true, expose: true}, + }, + + baz: { + flags: {update: true, expose: true}, + expose: { + transform: baz => baz * 2, + }, + }, + }; + }); + + thing.foo = 100; + thing.bar = 200; + thing.baz = 300; + + t.match(composite, { + expose: { + dependencies: ['object', 'property', 'internal'], + }, + }); + + t.equal(composite.expose.compute({ + object: thing, + property: 'foo', + internal: true, + }), 100); + + t.equal(composite.expose.compute({ + object: thing, + property: 'bar', + internal: true, + }), 200); + + t.equal(composite.expose.compute({ + object: thing, + property: 'baz', + internal: true, + }), 300); + + t.equal(composite.expose.compute({ + object: thing, + property: 'baz', + internal: false, + }), 600); + + t.equal(composite.expose.compute({ + object: thing, + property: 'bimbam', + internal: false, + }), null); + + t.equal(composite.expose.compute({ + object: null, + property: 'bambim', + internal: false, + }), null); +}); + t.test(`withPropertyFromObject: output shapes & values`, t => { t.plan(2 * 3 ** 2); |