Generic Tests - Unit
  • 05 Dec 2022
  • Dark
    Light
  • PDF

Generic Tests - Unit

  • Dark
    Light
  • PDF

Article summary

The following unit tests are consistent across all adapters. They should not be modified and will be updated when the adapter is migrated (the process of updating the adapter foundation).

Test Description
Class Tests that the adapter has been instantiated with the defined properties.
Adapter Base Tests for the existence of the adapter base.
Workflow Functions Tests for existing workflow functions. The results of these tests will be used in a later test.
Package Tests that the package.json file exists, it is a valid JSON, and that it has been customized for the adapter.
Pronghorn Tests that the pronghorn.json file exists, that it has been customized for the adapter, that the adapter.js methods and pronghorn.json methods are in sync, and all parameters match to reduce the risk of issues in the Itential Automation Platform (IAP) workflow tasks.
Properties Schema Tests that the propertiesSchema.json exists and that it has been customized for the adapter.
Error Tests that the error.json exists.
Sample Properties Tests that the sampleProperties.json exists.
Readme Tests that the README.md file exists and that it has been customized for the adapter.
Connect Tests that the connect method exists.
Healthcheck Tests that the healthCheck method exists.
Check Action Files Tests that the checkActionFiles method exists and it also checks all the action files against the actionSchema (done within the adapter library). Also checks that the referenced files exist. This prevents possible issues with actions not working later.
Encrypt Property Tests that the encryptProperty method exists. It will also test that encoding (b64) and encrypting (AES) of a property works as expected.

Example: Generic Tests

describe('#class instance created', () => {
  it('should be a class with properties', (done) => {

describe('adapterBase.js', () => {
  it('should have an adapterBase.js', (done) => {

describe('#getWorkflowFunctions', () => {
  it('should retrieve workflow functions', (done) => {

describe('package.json', () => {
  it('should have a package.json', (done) => {
  it('package.json should be validated', (done) => {
  it('package.json should be customized', (done) => {

describe('pronghorn.json', () => {
  it('should have a pronghorn.json', (done) => {
  it('pronghorn.json should be customized', (done) => {
  it('pronghorn.json should only expose workflow functions', (done) => {
  it('pronghorn.json should expose all workflow functions', (done) => {

describe('propertiesSchema.json', () => {
  it('should have a propertiesSchema.json', (done) => {
  it('propertiesSchema.json should be customized', (done) => {

describe('error.json', () => {
  it('should have an error.json', (done) => {

describe('sampleProperties.json', () => {
  it('should have a sampleProperties.json', (done) => {
  it('should have a checkProperties function', (done) => {
  it('the sample properties should be good - if failure change the log level', (done) => {

describe('README.md', () => {
  it('should have a README', (done) => {
  it('README.md should be customized', (done) => {

describe('#connect', () => {
  it('should have a connect function', (done) => {

describe('#healthCheck', () => {
  it('should have a healthCheck function', (done) => {

describe('#checkActionFiles', () => {
  it('should have a checkActionFiles function', (done) => {
  it('the action files should be good - if failure change the log level as most issues are warnings', (done) => {

describe('#encryptProperty', () => {
  it('should have a encryptProperty function', (done) => {
  it('should get base64 encoded property', (done) => {
  it('should get encrypted property', (done) => {

HAS ENTITY
This test is commented out for future use.

Note: There is a marker in the file to separate the generic part of the file from the customizable part.

ADAPTERTESTUNIT.JS

/*
-----------------------------------------------------------------------
-----------------------------------------------------------------------
*** All code above this comment will be replaced during a migration ***
******************* DO NOT REMOVE THIS COMMENT BLOCK ******************
-----------------------------------------------------------------------
-----------------------------------------------------------------------
*/

Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.