Skip to content

Commit

Permalink
expanded unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
geekmdtravis committed Apr 12, 2024
1 parent 1117a17 commit d3c215e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
35 changes: 34 additions & 1 deletion src/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CclCallParam } from './makeCclRequestAsync';
import { isCclCallParam } from './utils';
import { isCclCallParam, outsideOfPowerChartError } from './utils';

describe('isCclCallParam', () => {
it('should return true if the object is a CclCallParam', () => {
Expand Down Expand Up @@ -27,3 +27,36 @@ describe('isCclCallParam', () => {
expect(result).toBe(true);
});
});

describe('outsideOfPowerChartError', () => {
it('should return true if the error message contains "MPAGES_EVENT"', () => {
const error = new TypeError('MPAGES_EVENT is not a function');
const result = outsideOfPowerChartError(error);
expect(result).toBe(true);
});
it('should return true if the error message contains "XMLCclRequest"', () => {
const error = new TypeError('XMLCclRequest is not a function');
const result = outsideOfPowerChartError(error);
expect(result).toBe(true);
});
it('should return true if the error message contains "APPLINK"', () => {
const error = new TypeError('APPLINK is not a function');
const result = outsideOfPowerChartError(error);
expect(result).toBe(true);
});
it('should return true if the error message contains "DiscernObjectFactory"', () => {
const error = new TypeError('DiscernObjectFactory is not a function');
const result = outsideOfPowerChartError(error);
expect(result).toBe(true);
});
it('is case insensitive', () => {
const error = new TypeError('mpages_event is not a function');
const result = outsideOfPowerChartError(error);
expect(result).toBe(true);
});
it('should return false if the error message does not contain any of the expected strings', () => {
const error = new TypeError('test error');
const result = outsideOfPowerChartError(error);
expect(result).toBe(false);
});
});
10 changes: 0 additions & 10 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ export function outsideOfPowerChartError(e: unknown) {
);
}

/**
* A wrapper function for the `console.warn` function which logs a warning message.
* @param eventString {string} - The event string to be logged.
*/
export const warnAttemptedOrdersOutsideOfPowerChart = (
eventString: string
): void => {
console.warn(`window.MPAGES_EVENT('ORDERS', '${eventString}')`);
};

/**
* Check an object to see if it is a CclCallParam.
* @param param - an object of any type to check if it is a CclCallParam.
Expand Down

0 comments on commit d3c215e

Please sign in to comment.