Skip to content

Commit

Permalink
test(utils): increase test coverage chunk 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Arturo Riveron Borodovisina committed Mar 28, 2022
1 parent 679d32e commit e5a760c
Show file tree
Hide file tree
Showing 25 changed files with 1,172 additions and 28 deletions.
5 changes: 2 additions & 3 deletions src/util.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/* @flow */
/* eslint max-lines: 0 */

Expand Down Expand Up @@ -557,7 +556,7 @@ export function objFilter<T, R>(obj : { [string] : T }, filter? : (T, ?string) =
const result = {};
for (const key in obj) {
if (!obj.hasOwnProperty(key) || !filter(obj[key], key)) {
if (!obj.hasOwnProperty(key) || (filter && !filter(obj[key], key))) {
continue;
}
Expand Down Expand Up @@ -687,7 +686,7 @@ export function undotify(obj : { [string] : string }) : Object {
} else {
value = deserializePrimitive(value);
}
let keyResult = result;
const parts = key.split('.');
for (let i = 0; i < parts.length; i++) {
Expand Down
1 change: 1 addition & 0 deletions test/tests/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('experiment', () => {
}
delete window.__goku__latest_global__;
});

it('should return default value from the namespace', () => {
const { get } = getGlobalNameSpace({ name: 'goku' });
const res = get('vegeta', 'testingDatDefaultValue');
Expand Down
28 changes: 28 additions & 0 deletions test/tests/util/awaitKey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* @flow */

import { awaitKey } from '../../../src';

describe('awaitKey cases', () => {
it('awaitKey should return the value when existing', () => {
const obj = {
custom: true
};
const result = awaitKey(obj, 'custom');

if (!result) {
throw new Error(`should return "true", but got: ${ result }`);
}
});

it('awaitKey should return the configured value when does not exists', () => {
const obj = {};

awaitKey(obj, 'custom');
obj.custom = 'result';
const result = obj.custom;

if (result !== 'result') {
throw new Error(`should return "result", but got: ${ result }`);
}
});
});
17 changes: 0 additions & 17 deletions test/tests/util/base64encode.js

This file was deleted.

Loading

0 comments on commit e5a760c

Please sign in to comment.