UNPKG

noflo

Version:

Flow-Based Programming environment for JavaScript

574 lines (552 loc) 36.1 kB
  Legacy ArrayPort  Untyped ArrayPort instance   ✓ should be of type "all"  ArrayPort instance   ✓ should retain the given type  without attached socket   ✓ should not be attached initially   ✓ should allow connections   ✓ should not be connected initially   ✓ should not contain a socket initially   ✓ should not allow connecting   ✓ should not allow beginning groups   ✓ should not allow sending data   ✓ should not allow ending groups   ✓ should not allow disconnecting  with attached socket   ✓ should emit an event   ✓ should be marked as attached   ✓ should still allow more connections   ✓ should not be connected initially   ✓ should have a reference to the socket   ✓ should allow other sockets to be attached   ✓ should emit an event on detaching   ✓ should not be attached any longer   ✓ should not contain the removed socket any longer  Input ArrayPort   ✓ should emit connection events   ✓ should be connected after that   ✓ should emit begin group events   ✓ should emit data events   ✓ should emit end group events   ✓ should emit disconnection events   ✓ should not be connected after that   ✓ should connect automatically when sending  Input ArrayPort with specified index   ✓ shouldn't be attached initially   ✓ should emit attaching events   ✓ should be attached after that   ✓ shouldn't have other indexes attached after that   ✓ should emit connection events   ✓ should be connected after that   ✓ shouldn't have other indexes connected after that   ✓ should emit begin group events   ✓ should emit data events   ✓ should emit end group events   ✓ should emit disconnection events   ✓ should not be connected after that   ✓ should connect automatically when sending   ✓ should emit attaching events   ✓ shouldn't be attached after that  Output ArrayPort   ✓ should connect the socket   ✓ should begin groups on the socket   ✓ should send data to the socket   ✓ should end groups on the socket   ✓ should disconnect the socket   ✓ should connect automatically when sending  AsyncComponent with missing ports   ✓ should throw an error on instantiation when no IN defined   ✓ should throw an error on instantion when no OUT defined  AsyncComponent without a doAsync method   ✓ should throw an error if there is no connection to the ERROR port   ✓ should send an error to the ERROR port if connected   ✓ should send groups and error to the ERROR port if connected  Implemented AsyncComponent   ✓ should send load information and packets in correct order (301ms)  Component  with required ports   ✓ should throw an error upon sending packet to an unattached required port   ✓ should be cool with an attached port  with component creation shorthand   ✓ should make component creation easy   ✓ should throw errors if there is no error port   ✓ should throw errors if there is a non-attached error port   ✓ should not throw errors if there is a non-required error port   ✓ should send errors if there is a connected error port  defining ports with invalid names   ✓ should throw an error with uppercase letters in inport   ✓ should throw an error with uppercase letters in outport   ✓ should throw an error with special characters in inport  starting a component   ✓ should flag the component as started  shutting down a component   ✓ should flag the component as not started  with object-based IPs   ✓ should speak IP objects   ✓ should support substreams  with process function   ✓ should trigger on IPs   ✓ should not be triggered by non-triggering ports   ✓ should fetch undefined for premature data   ✓ should receive and send complete IP objects   ✓ should receive and send just IP data if wanted   ✓ should keep last value for controls   ✓ should keep last data-typed IP packet for controls   ✓ should isolate packets with different scopes   ✓ should be able to change scope   ✓ should preserve order between input and output   ✓ should ignore order between input and output   ✓ should throw errors if there is no error port   ✓ should throw errors if there is a non-attached error port   ✓ should not throw errors if there is a non-required error port   ✓ should send errors if there is a connected error port   ✓ should send substreams with multiple errors per activation   ✓ should forward brackets for map-style components   ✓ should support custom bracket forwarding mappings with auto-ordering   ✓ should forward IP metadata for map-style components  with custom callbacks   ✓ should fail on wrong input   ✓ should send substreams  ComponentLoader with no external packages installed   ✓ should initially know of no components   ✓ should not initially require revalidation   ✓ should not initially be ready   ✓ should not initially be processing   ✓ should not have any packages in the checked list   ✓ should be able to read a list of components  normalizing names   ✓ should return simple module names as-is   ✓ should return empty for NoFlo core   ✓ should strip noflo-   ✓ should strip NPM scopes   ✓ should strip NPM scopes and noflo-  after listing components   ✓ should have the Graph component registered  loading the Graph component   ✓ should be able to load the component   ✓ should contain input ports   ✓ should have "on" method on the input port   ✓ it should know that Graph is a subgraph   ✓ should know the description for the Graph   ✓ should be able to provide an icon for the Graph  loading the Graph component   ✓ should be able to load the component   ✓ should have a reference to the Component Loader's baseDir  loading a component   ✓ should return an error on an invalid component type  register a component at runtime   ✓ should be available in the components list   ✓ should be able to load the component   ✓ should have the correct ports   ✓ should have inherited its icon from the library   ✓ should emit an event on icon change   ✓ new instances should still contain the original icon   ✓ after setting an icon for the Component class, new instances should have that   ✓ should not affect the original instance  reading sources   ✓ should be able to provide source code for a component   ✓ should return an error for missing components   ✓ should return an error for non-file components  writing sources  with working code   ✓ should be able to set the source   ✓ should be a loadable component  with non-working code   ✓ should be able to set the source   ✓ should not be a loadable component  ComponentLoader with a fixture project  - should be possible to instantiate  - should initially know of no components  - should not initially be ready  - should be able to read a list of components  - should be able to load a local component  - should be able to load a component from a dependency  - should be able to load a dynamically registered component from a dependency  - should be able to load core Graph component  - should fail loading a missing component  Unnamed graph instance   ✓ should have an empty name  Graph  with new instance   ✓ should get a name from constructor   ✓ should have no nodes initially   ✓ should have no edges initially   ✓ should have no initializers initially   ✓ should have no exports initially  New node   ✓ should emit an event   ✓ should be in graph's list of nodes   ✓ should be accessible via the getter   ✓ should have empty metadata   ✓ should be available in the JSON export   ✓ removing should emit an event   ✓ should not be available after removal  New edge   ✓ should emit an event   ✓ should add an edge   ✓ should refuse to add a duplicate edge  New edge with index   ✓ should emit an event   ✓ should add an edge  loaded from JSON   ✓ should produce a Graph   ✓ should have a name   ✓ should have graph metadata intact   ✓ should produce same JSON when serialized   ✓ should allow modifying graph metadata   ✓ should contain four nodes   ✓ the first Node should have its metadata intact   ✓ should allow modifying node metadata   ✓ should contain two connections   ✓ the first Edge should have its metadata intact   ✓ should allow modifying edge metadata   ✓ should contain four IIPs   ✓ should contain one published inport   ✓ should contain one published outport   ✓ should keep the output export metadata intact   ✓ should contain two groups   ✓ should allow modifying group metadata   ✓ should allow renaming groups  renaming a node   ✓ should emit an event   ✓ should be available with the new name   ✓ shouldn't be available with the old name   ✓ should have the edge still going from it   ✓ should still be exported   ✓ should still be grouped   ✓ shouldn't be have edges with the old name   ✓ should have the IIP still going to it   ✓ shouldn't have IIPs going to the old name   ✓ shouldn't be have export going to the old name   ✓ shouldn't be grouped with the old name  renaming an inport   ✓ should emit an event  renaming an outport   ✓ should emit an event  removing a node   ✓ should emit an event   ✓ shouldn't have edges left behind   ✓ shouldn't have IIPs left behind   ✓ shouldn't have exports left behind   ✓ shouldn't be grouped   ✓ shouldn't affect other groups  with multiple connected ArrayPorts   ✓ should contain four nodes   ✓ should contain four edges   ✓ should allow a specific edge to be removed   ✓ shouldn't contain the removed connection from Split1   ✓ should still contain the other connection from Split1  with an Initial Information Packet   ✓ should contain one node   ✓ should contain no edges   ✓ should contain one IIP  on removing that IIP   ✓ should emit a removeInitial event   ✓ should contain no IIPs  with an Inport Initial Information Packet   ✓ should contain one node   ✓ should contain no edges   ✓ should contain one IIP for the correct node  on removing that IIP   ✓ should emit a removeInitial event   ✓ should contain no IIPs  on adding IIP for a non-existent inport   ✓ should not add any IIP  with an indexed Inport Initial Information Packet   ✓ should contain one node   ✓ should contain no edges   ✓ should contain one IIP for the correct node  on removing that IIP   ✓ should emit a removeInitial event   ✓ should contain no IIPs  on adding IIP for a non-existent inport   ✓ should not add any IIP  with no nodes   ✓ should not allow adding edges   ✓ should not allow adding IIPs  Legacy exports loaded via JSON   ✓ should produce a Graph   ✓ should have two legacy exports   ✓ should fix the case of the process key  Inport Port  with default options   ✓ should be of datatype "all"   ✓ should not be required   ✓ should not be addressable   ✓ should not be buffered  with custom type   ✓ should retain the type  without attached sockets   ✓ should not be attached   ✓ should allow attaching   ✓ should not be connected initially   ✓ should not contain a socket initially  with processing function called with port as context   ✓ should set context to port itself  with default value   ✓ should send the default value as a packet, though on next tick after initialization   ✓ should send the default value before IIP  with options stored in port   ✓ should store all provided options in port, whether we expect it or not  with data type information   ✓ should accept a 'all' data type   ✓ should accept a 'string' data type   ✓ should accept a 'number' data type   ✓ should accept a 'int' data type   ✓ should accept a 'object' data type   ✓ should accept a 'array' data type   ✓ should NOT accept a 'not' data type   ✓ should NOT accept a 'valie' data type   ✓ should NOT accept a 'data' data type   ✓ should NOT accept a 'types' data type  with TYPE (i.e. ontology) information   ✓ should be a URL or MIME  with buffering   ✓ should buffer incoming packets until `receive()`d   ✓ should be able to tell the number of contained data packets   ✓ should return undefined when buffer is empty   ✓ shouldn't expose the receive method without buffering  with accepted enumerated values   ✓ should accept certain values   ✓ should throw an error if value is not accepted  with processing shorthand   ✓ should create a port with a callback   ✓ should also accept metadata (i.e. options) when provided  with IP handle callback option   ✓ should pass IP objects to handler   ✓ should translate legacy events to IP objects   ✓ should translate IP objects to legacy events  Component traits  MapComponent   ✓ should pass data to the callback   ✓ should pass groups to the callback   ✓ should send groups and disconnect through  WirePattern  when grouping by packet groups   ✓ should pass data and groups to the callback   ✓ should work without a group provided   ✓ should process inputs for different groups independently with group: true   ✓ should support asynchronous handlers (102ms)   ✓ should not forward groups if forwarding is off   ✓ should forward groups from a specific port only   ✓ should forward groups from selected ports only  when `this` context is important   ✓ should correctly bind component to `this` context   ✓ should correctly bind component to `this` context in async mode  when in async mode and packet order matters   ✓ should preserve input order at the output   ✓ should support complex substreams  when grouping by field   ✓ should match objects by specific field (44ms)  when there are multiple output routes   ✓ should send output to one or more of them  when there are parameter ports   ✓ should wait for required params without default value   ✓ should work for async procs too (60ms)   ✓ should reset state if shutdown() is called   ✓ should drop premature data if configured to do so  without output ports   ✓ should be fine still  when data processing is not possible at the moment   ✓ should be able to postpone it until next tuple of data   ✓ should be able to postpone and retry after timeout   ✓ should be able to postpone it and resume when needed  with many inputs and groups   ✓ should handle mixed flow well (310ms)  for batch processing   ✓ should process sequences of packets separated by disconnects  for batch processing with groups   ✓ should wrap entire sequence with groups  with addressable ports   ✓ should wait for all param and any data port values (default)   ✓ should wait for any param and all data values   ✓ should wait for all indexes of a single input   ✓ should behave normally with string output from another component  when grouping requests   ✓ should group requests by outer UUID group (105ms)   ✓ should collect garbage every N requests   ✓ should be able to drop a request explicitly  MultiError  with simple sync processes   ✓ should support multiple customized error messages   ✓ should pass if everything is correct   ✓ should handle fatals and runtimes normally  with async processes and groups   ✓ should support multiple error messages and groups   ✓ should pass if everything is correct   ✓ should handle fatals and runtimes normally   ✓ should reset state if component is shut down  Journal  connected to initialized graph   ✓ should have just the initial transaction  following basic graph changes   ✓ should create one transaction per change  pretty printing   ✓ should be human readable  jumping to revision   ✓ should change the graph  linear undo/redo   ✓ undo should restore previous revision   ✓ redo should apply the same change again   ✓ undo should also work multiple revisions back  undo/redo of metadata changes   ✓ adding group   ✓ undoing group add   ✓ redoing group add   ✓ changing group metadata adds revision   ✓ undoing group metadata change   ✓ redoing group metadata change   ✓ setting node metadata   ✓ undoing set node metadata   ✓ redoing set node metadata  Journalling of graph merges  G -> B   ✓ G starts out as A   ✓ G and B starts out different   ✓ merge should make G equivalent to B   ✓ undoing merge should make G equivalent to A again  NoFlo Network  with an empty graph   ✓ should initially be marked as stopped   ✓ should initially have no processes   ✓ should initially have to connections   ✓ should initially have no IIPs   ✓ should have reference to the graph   ✓ should know its baseDir   ✓ should have a ComponentLoader   ✓ should have transmitted the baseDir to the Component Loader   ✓ should be able to list components   ✓ should have an uptime  with new node   ✓ should contain the node   ✓ should have transmitted the node metadata to the process   ✓ should not contain the node after removal  with a simple graph   ✓ should contain two processes   ✓ the ports of the processes should know the node names   ✓ should contain one connection   ✓ should call callback when receiving data   ✓ should have started in debug mode   ✓ should emit a process-error when a component throws  once started   ✓ should be marked as started  with a renamed node   ✓ should have the process in a new location   ✓ shouldn't have the process in the old location   ✓ should have informed the ports of their new node name  with process icon change   ✓ should emit an icon event  once stopped   ✓ should be marked as stopped  with nodes containing default ports   ✓ should send default values to nodes without an edge   ✓ should not send default values to nodes with an edge   ✓ should not send default values to nodes with IIP  Nodes are added first, then edges, then initializers (i.e. IIPs), and in order of definition order within each   ✓ should add nodes, edges, and initials, in that order  with an existing IIP   ✓ should call the Callback with the original IIP value   ✓ should allow removing the IIPs   ✓ new IIPs to replace original ones should work correctly  on stopping   ✓ processes should be running before the stop call   ✓ should emit the end event   ✓ should have called the shutdown method of each process  with a very large network   ✓ should be able to connect without errors (4874ms)  NoFlo interface   ✓ should be able to tell whether it is running on browser  Outport Port  with addressable ports   ✓ should be able to send to a specific port   ✓ should be able to send to index 0   ✓ should throw an error when sent data without address   ✓ should throw an error when a specific port is requested with non-addressable port   ✓ should give correct port index when detaching a connection  with caching ports   ✓ should repeat the previously sent value on attach event   ✓ should support addressable ports  with IP objects   ✓ should send data IPs and substreams   ✓ should send non-clonable objects by reference   ✓ should clone clonable objects on fan-out  Legacy Port  Untyped port instance   ✓ should be of type "all"  Port instance  initially   ✓ should retain the given type   ✓ should not have a name   ✓ should not have a node name   ✓ should return "Port" as identifier  with given name and node   ✓ should return correct ID  without attached socket   ✓ should not be attached initially   ✓ should allow a connection   ✓ should not be connected initially   ✓ should not contain a socket initially   ✓ should not allow connecting   ✓ should not allow beginning groups   ✓ should not allow sending data   ✓ should not allow ending groups   ✓ should not allow disconnecting  with attached socket   ✓ should emit an event   ✓ should be marked as attached   ✓ should not be connected initially   ✓ should have a reference to the socket   ✓ should allow other sockets to be attached   ✓ should emit an event on detaching   ✓ should still be attached   ✓ should not be attached any longer   ✓ should not contain a socket any longer  Input port   ✓ should emit connection events   ✓ should be connected after that   ✓ should emit begin group events   ✓ should emit data events   ✓ should emit end group events   ✓ should emit disconnection events   ✓ should not be connected after that   ✓ should connect automatically when sending  Output port   ✓ should connect the socket   ✓ should begin groups on the socket   ✓ should send data to the socket   ✓ should end groups on the socket   ✓ should disconnect the socket   ✓ should connect automatically when sending  Graph component  initially   ✓ should be ready   ✓ should not contain a network   ✓ should not have a baseDir   ✓ should only have the graph inport  with JSON graph definition   ✓ should emit a ready event after network has been loaded   ✓ should expose available ports   ✓ should update description from the graph   ✓ should expose only exported ports when they exist   ✓ should be able to run the graph  with a Graph instance   ✓ should emit a ready event after network has been loaded   ✓ should expose available ports   ✓ should be able to run the graph  with a FBP file with INPORTs and OUTPORTs   ✓ should emit a ready event after network has been loaded   ✓ should expose available ports (46ms)   ✓ should be able to run the graph (47ms)  with a FBP file with legacy EXPORTS   ✓ should emit a ready event after network has been loaded (47ms)   ✓ should expose available ports (41ms)   ✓ should have disambiguated the exported ports (42ms)   ✓ should be able to run the graph (43ms)  when a subgraph is used as a component   ✓ should send defaults   ✓ should send initials   ✓ should not send defaults when an inport is attached externally   411 passing (7s)   9 pending