Skip to content

Instantly share code, notes, and snippets.

@VivekNayyar
Created November 4, 2018 20:05
Show Gist options
  • Save VivekNayyar/3a9b33e397b3312902fa21dc5529ed4f to your computer and use it in GitHub Desktop.
Save VivekNayyar/3a9b33e397b3312902fa21dc5529ed4f to your computer and use it in GitHub Desktop.
import { util } from '../helpers/utils';
describe('test cases for the exported util object', () => {
test('exported object to be defined', () => {
expect(util).toBeDefined();
});
test('util should be an object', () => {
expect(typeof util).toBe('object');
});
});
describe('test cases for parseHeader', () => {
test('should be defined', () => {
expect(util.parseHeader).toBeDefined();
});
test('should return null if no requestHeader prop passed', () => {
const output = util.parseHeader();
expect(output).toBeNull();
});
test('should return the value of the header', () => {
const headerName = 'Retry-Time';
const expectedRetryTime = 3600;
const requestObject = {
headers: {
[headerName]: expectedRetryTime
}
};
const output = util.parseHeader(requestObject, headerName);
expect(output).toBe(expectedRetryTime);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment