diff --git a/codecov.yml b/codecov.yml index 245a63ec71..30b299937a 100644 --- a/codecov.yml +++ b/codecov.yml @@ -14,8 +14,6 @@ coverage: range: "66...100" ignore: - - "**/*Spec.js" - - "e2e" parsers: gcov: diff --git a/karma.conf.js b/karma.conf.js index e0afe2ee16..5c51e9f3f2 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -33,11 +33,10 @@ if (coverageEnabled) { module.exports = (config) => { const webpackConfig = require('./webpack.dev.js'); delete webpackConfig.output; - if (coverageEnabled) { webpackConfig.module.rules.push({ test: /\.js$/, - exclude: /node_modules|example|lib|dist/, + exclude: /node_modules|e2e|example|lib|dist|\.*.*Spec\.js/, use: { loader: 'istanbul-instrumenter-loader', options: { @@ -103,7 +102,7 @@ module.exports = (config) => { reports: ['lcovonly', 'text-summary'], thresholds: { global: { - lines: 66 + lines: 55 } } }, diff --git a/src/tools/url.js b/src/tools/url.js index fdd7043753..3d1817e3e9 100644 --- a/src/tools/url.js +++ b/src/tools/url.js @@ -25,7 +25,7 @@ */ export function paramsToArray(openmct) { - // parse urParams from an object to an array. + // parse urlParams from an object to an array. let urlParams = openmct.router.getParams(); let newTabParams = []; for (let key in urlParams) { diff --git a/src/tools/urlSpec.js b/src/tools/urlSpec.js new file mode 100644 index 0000000000..36a31324db --- /dev/null +++ b/src/tools/urlSpec.js @@ -0,0 +1,70 @@ +import { createOpenMct, resetApplicationState } from "../utils/testing"; +import {paramsToArray, identifierToString, default as objectPathToUrl} from "./url"; + +describe('the url tool', function () { + let openmct; + let mockObjectPath; + + beforeEach((done) => { + mockObjectPath = [ + { + name: 'mock folder', + type: 'fake-folder', + identifier: { + key: 'mock-folder', + namespace: '' + } + }, + { + name: 'mock parent folder', + type: 'fake-folder', + identifier: { + key: 'mock-parent-folder', + namespace: '' + } + } + ]; + openmct = createOpenMct(); + openmct.on('start', () => { + openmct.router.setPath(' http://localhost:8020/foobar?testParam1=testValue1'); + done(); + }); + openmct.startHeadless(); + }); + + afterEach(() => { + return resetApplicationState(openmct); + }); + + describe('paramsToArray', () => { + it('exists', () => { + expect(paramsToArray).toBeDefined(); + }); + it('can construct an array properly from query parameters', () => { + const arrayOfParams = paramsToArray(openmct); + expect(arrayOfParams.length).toBeDefined(); + expect(arrayOfParams.length).toBeGreaterThan(0); + }); + }); + + describe('identifierToString', () => { + it('exists', () => { + expect(identifierToString).toBeDefined(); + }); + it('can construct a String properly from a path', () => { + const constructedString = identifierToString(openmct, mockObjectPath); + expect(constructedString).toEqual('#/browse/mock-parent-folder/mock-folder'); + }); + + }); + + describe('objectPathToUrl', () => { + it('exists', () => { + expect(objectPathToUrl).toBeDefined(); + }); + it('can construct URL properly from a path', () => { + const constructedURL = objectPathToUrl(openmct, mockObjectPath); + expect(constructedURL).toContain('#/browse/mock-parent-folder/mock-folder'); + }); + }); +});