Skip to content

Commit 1003dbe

Browse files
committed
more pr feedback
1 parent b493c1d commit 1003dbe

File tree

5 files changed

+64
-51
lines changed

5 files changed

+64
-51
lines changed

mocks/deepmerge.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,26 @@ export type DeepPartial<T> = T extends Function
88
? { [K in keyof T]?: DeepPartial<T[K]> }
99
: T;
1010

11+
/**
12+
* Recursively merges a patch object into a target object.
13+
*
14+
* Behavior:
15+
* - Primitive values, nulls, and functions from patch replace target values
16+
* - Arrays from patch replace target arrays entirely
17+
* - Plain objects are recursively merged
18+
* - Undefined values in patch are skipped (target values are preserved)
19+
*
20+
* @template T - The type of the target object
21+
* @param target - The base object to merge into
22+
* @param patch - The partial object with values to merge; undefined/null values are ignored
23+
* @returns A new merged object of type T
24+
*
25+
* @example
26+
* const base = { a: 1, b: { c: 2 } };
27+
* const patch = { b: { c: 3 } };
28+
* const result = deepMerge(base, patch);
29+
* // Result: { a: 1, b: { c: 3 } }
30+
*/
1131
export function deepMerge<T>(target: T, patch: DeepPartial<T>): T {
1232
if (patch === undefined || patch === null) return target;
1333

@@ -38,5 +58,3 @@ export function deepMerge<T>(target: T, patch: DeepPartial<T>): T {
3858

3959
return out as T;
4060
}
41-
42-
export const asDeepPartial = <T>(v: DeepPartial<T>) => v;

www/DebugNamespace.test.ts

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,42 +14,48 @@ describe('Debug', () => {
1414
});
1515

1616
test.each([
17-
[LogLevel.None],
18-
[LogLevel.Fatal],
19-
[LogLevel.Error],
20-
[LogLevel.Warn],
21-
[LogLevel.Info],
22-
[LogLevel.Debug],
23-
[LogLevel.Verbose],
24-
])('should call cordova.exec for setLogLevel with %s', (logLevel) => {
25-
debug.setLogLevel(logLevel);
17+
[LogLevel.None, 0],
18+
[LogLevel.Fatal, 1],
19+
[LogLevel.Error, 2],
20+
[LogLevel.Warn, 3],
21+
[LogLevel.Info, 4],
22+
[LogLevel.Debug, 5],
23+
[LogLevel.Verbose, 6],
24+
])(
25+
'should call cordova.exec for setLogLevel with %s',
26+
(logLevel, logLevelValue) => {
27+
debug.setLogLevel(logLevel);
2628

27-
expect(window.cordova.exec).toHaveBeenCalledWith(
28-
expect.any(Function),
29-
expect.any(Function),
30-
'OneSignalPush',
31-
'setLogLevel',
32-
[logLevel],
33-
);
34-
});
29+
expect(window.cordova.exec).toHaveBeenCalledWith(
30+
expect.any(Function),
31+
expect.any(Function),
32+
'OneSignalPush',
33+
'setLogLevel',
34+
[logLevelValue],
35+
);
36+
},
37+
);
3538

3639
test.each([
37-
[LogLevel.None],
38-
[LogLevel.Fatal],
39-
[LogLevel.Error],
40-
[LogLevel.Warn],
41-
[LogLevel.Info],
42-
[LogLevel.Debug],
43-
[LogLevel.Verbose],
44-
])('should call cordova.exec for setAlertLevel with %s', (logLevel) => {
45-
debug.setAlertLevel(logLevel);
40+
[LogLevel.None, 0],
41+
[LogLevel.Fatal, 1],
42+
[LogLevel.Error, 2],
43+
[LogLevel.Warn, 3],
44+
[LogLevel.Info, 4],
45+
[LogLevel.Debug, 5],
46+
[LogLevel.Verbose, 6],
47+
])(
48+
'should call cordova.exec for setAlertLevel with %s',
49+
(logLevel, logLevelValue) => {
50+
debug.setAlertLevel(logLevel);
4651

47-
expect(window.cordova.exec).toHaveBeenCalledWith(
48-
expect.any(Function),
49-
expect.any(Function),
50-
'OneSignalPush',
51-
'setAlertLevel',
52-
[logLevel],
53-
);
54-
});
52+
expect(window.cordova.exec).toHaveBeenCalledWith(
53+
expect.any(Function),
54+
expect.any(Function),
55+
'OneSignalPush',
56+
'setAlertLevel',
57+
[logLevelValue],
58+
);
59+
},
60+
);
5561
});

www/InAppMessagesNamespace.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
InAppMessageDidDisplayEvent,
88
InAppMessageWillDisplayEvent,
99
} from './types/InAppMessage';
10+
1011
describe('InAppMessages', () => {
1112
let inAppMessages: InAppMessages;
1213

www/NotificationsNamespace.test.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Notifications, {
55
OSNotificationPermission,
66
} from './NotificationsNamespace';
77
import * as helpers from './helpers';
8+
89
describe('Notifications', () => {
910
let notifications: Notifications;
1011

@@ -348,18 +349,6 @@ describe('Notifications', () => {
348349
[notificationId],
349350
);
350351
});
351-
352-
test('should call cordova.exec for removeNotification with different IDs', () => {
353-
notifications.removeNotification(456);
354-
355-
expect(window.cordova.exec).toHaveBeenCalledWith(
356-
expect.any(Function),
357-
expect.any(Function),
358-
'OneSignalPush',
359-
'removeNotification',
360-
[456],
361-
);
362-
});
363352
});
364353

365354
describe('removeGroupedNotifications', () => {
@@ -391,7 +380,7 @@ describe('Notifications', () => {
391380
expect(result).toBe(true);
392381
});
393382

394-
test('should return test when permission is set via permission listener', () => {
383+
test('should return true when permission is set via permission listener', () => {
395384
notifications._setPropertyAndObserver();
396385
const callback = mockExec.mock.calls.find(
397386
(call) => call[3] === 'addPermissionObserver',

www/OSNotification.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { mockCordova } from '../mocks/cordova';
22
import { OSNotification } from './OSNotification';
33

4-
type RequireOptional<T> = Required<T>;
5-
type AllProperties = RequireOptional<Omit<OSNotification, 'display'>>;
4+
type AllProperties = Required<Omit<OSNotification, 'display'>>;
65

76
describe('OSNotification', () => {
87
beforeEach(() => {

0 commit comments

Comments
 (0)