Testing Tips

When embedding a KronoGraph timeline into your app, you may be interested in automated integration testing. This section outlines the APIs that KronoGraph provides for obtaining information about entities and events in the timeline which you can then use within your chosen test framework.

Handled Events

The draw event The onTimelineDraw event is fired each time the timeline is rendered. This can include animated transitions, so we recommend using setTimeout() in your tests to allow any animations to finish before making assertions.

Methods

The following timeline instance methods are particularly useful for integration tests.

If you're going to use a tool to inspect the timeline in a given window, give access to the timeline by exposing the timeline ref to the window:

const MyFunctionalComponent = () => {
  const timelineRef = useRef(null);

  useEffect(() => {
    if (typeof window !== "undefined") {
      // expose the ref on the top-most window
      window.top.timeline = timelineRef.current;
    }
  }, []);

  return (
      <Timeline
        ref={timelineRef}
        entities={data.entities}
        events={data.events}
      />
  );
};

You can then use the ref:

const entityColor = timelineRef.current.getEntity('entity a').color;
The function...Can be used to test whether...
getAnnotationBodyPosition the specified annotation is in the current timeline range: returns null if not.
getEntityPosition there's an entity in the current timeline range, in the specified position: returns null if not.
getEventPosition there's an event in the current timeline range, in the specified position: returns null if not.
getInRangeItems
  • there are any events and entities in the current timeline range: returns an empty object if not.
  • there are any focused entities in the current timeline range by specifying the focus option: returns an empty object if not.

If you're going to use a tool to inspect the timeline in a given window, you need to make it available to the global scope. This allows you to then use a function such as timeline.options(), for example, to get the timeline's current options.

The function...Can be used to test whether...
getAnnotationBodyPosition the specified annotation is in the current timeline range: returns null if not.
getEntitythere's an entity with the specified id: returns null if not.
getEntityPosition there's an entity in the current timeline range, in the specified position: returns null if not.
getEventthere's an event with the specified id: returns null if not.
getEventPosition there's an event in the current timeline range, in the specified position: returns null if not.
getInRangeItems
  • there are any events and entities in the current timeline range: returns an empty object if not.
  • there are any focused entities in the current timeline range by specifying the focus option: returns an empty object if not.
getPinnedEntityIdsthere are any pinned entities: returns an empty object if not.
getRowEntityIdsthere's an entity row with the specified id: returns null if not.

Terms of use

These terms do not alter or supersede any existing agreements between you (or your employer) and us.

By accessing or using any Content you agree to be bound by these Terms of Use. Please review these terms carefully before using the website.

The contents of this website, including but not limited to any text, code samples, API references, schemas, interactive tools, and other materials (collectively, the 'Content'), are made available for informational and internal evaluation purposes only. All intellectual property rights in the Content are reserved. No licence is granted to use the Content for any commercial purpose, or to copy, distribute, modify, reverse-engineer, or incorporate any part of the Content into any product or service, without our prior written consent.

This Content is provided “as is” and “as available,” without any representations, warranties, or guarantees of any kind, whether express or implied, including but not limited to implied warranties of merchantability, fitness for a particular purpose, non-infringement, or accuracy. To the fullest extent permitted by applicable law, we expressly exclude and disclaim all implied warranties, conditions, and other terms that might otherwise be implied.

We disclaim all liability for any loss or damage, whether direct, indirect, incidental, consequential, or otherwise, arising from any reliance placed on the Content or from your use of it, to the fullest extent permitted by applicable law. By continuing to access or use the Content, you acknowledge and agree to these terms.