insomnia/packages/insomnia-app/app/models/__tests__/index.test.ts
Dimitri Mitropoulos 5f4c19da35
[TypeScript] Phase 1 & 2 (#3370)
Co-authored-by: Opender Singh <opender.singh@konghq.com>
2021-05-12 18:35:00 +12:00

29 lines
849 B
TypeScript

import { globalBeforeEach } from '../../__jest__/before-each';
import { getModel, mustGetModel } from '../index';
import * as models from '../index';
describe('index', () => {
beforeEach(globalBeforeEach);
describe('getModel()', () => {
it('should get model if found', () => {
expect(getModel(models.workspace.type)).not.toBeNull();
});
it('should return null if model not found', () => {
expect(getModel('UNKNOWN')).toBeNull();
});
});
describe('mustGetModel()', () => {
it('should get model if found', () => {
expect(mustGetModel(models.workspace.type)).not.toBeNull();
});
it('should return null if model not found', () => {
const func = () => mustGetModel('UNKNOWN');
expect(func).toThrowError('The model type UNKNOWN must exist but could not be found.');
});
});
});