Skip to content

Commit 80febd8

Browse files
committed
Improved Coverage
1 parent 4ed5f3d commit 80febd8

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/api/global.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import global from './global.js';
2+
import * as api from './api.js';
23
import vuexInstance from '../vuexInstance.js';
34

45
beforeEach(() => {
@@ -12,6 +13,14 @@ beforeEach(() => {
1213
};
1314
});
1415

16+
describe('global.api', () => {
17+
it('returns the api', () => {
18+
const newApi = { id: 42 };
19+
api.setApi(newApi);
20+
expect(global.api).toEqual(newApi);
21+
});
22+
});
23+
1524
describe('global.get', () => {
1625
it('returns getter value for fullpath', () => {
1726
global.get('foo/bar');

src/common/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const getStoreInstanceName = (storeName, instance) => {
77

88

99
export const toCamelCase = (str) => {
10-
if (!str) {
10+
if (!str || typeof str !== 'string') {
1111
return '';
1212
}
1313
return str.replace(/(-|_)([\w])/g, s => s[1].toUpperCase());

src/common/helpers.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ describe('helpers.toCamelCase', () => {
2323
it('keeps camel case intact', () => {
2424
expect(helpers.toCamelCase('aFooBarA$b')).toEqual('aFooBarA$b');
2525
});
26+
it('returns empty string if invalid value', () => {
27+
expect(helpers.toCamelCase(undefined)).toEqual('');
28+
expect(helpers.toCamelCase(5)).toEqual('');
29+
});
2630
});
2731

2832
describe('helpers.getLocalPath', () => {
@@ -121,4 +125,8 @@ describe('helpers.getSubInstances', () => {
121125
it('returns all instances from substring', () => {
122126
expect(helpers.getSubInstances('a$a1/b/c$c1/d')).toEqual(['$a1', '$c1']);
123127
});
128+
129+
it('returns empty array on empty path', () => {
130+
expect(helpers.getSubInstances('')).toEqual([]);
131+
});
124132
});

0 commit comments

Comments
 (0)