diff --git a/src/labkey/dom/Utils.spec.ts b/src/labkey/dom/Utils.spec.ts new file mode 100644 index 00000000..213b04b4 --- /dev/null +++ b/src/labkey/dom/Utils.spec.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2020 LabKey Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { loadDOMContext } from './constants'; + +describe('loadDOMContext', () => { + + it('Error without jQuery', () => { + const { $ } = loadDOMContext(); + expect(() => { $(); }).toThrowError('jQuery'); + }); +}); \ No newline at end of file diff --git a/src/labkey/dom/constants.ts b/src/labkey/dom/constants.ts index 96cec422..9587f2ca 100644 --- a/src/labkey/dom/constants.ts +++ b/src/labkey/dom/constants.ts @@ -34,7 +34,9 @@ if (typeof jQuery !== 'undefined') { LABKEY.$ = jQuery; } else { - console.warn('jQuery not available. When using the DOM version of the LabKey API jQuery is expected to be available.'); + LABKEY.$ = () => { + throw new Error('jQuery not available. When using the DOM version of the LabKey API jQuery is expected to be available.'); + }; } export function loadDOMContext(): LabKeyDOM {