mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-11-11 15:51:06 +00:00
9e587e5fe3
When using an app such as Gmail, the unread count is included in the title, and the --counter feature displays that number on the dock icon. However, when the number is larger than 999, it includes commas in the number (e.g. "1,000"), and the number is no longer displayed on the dock icon, because the regular expression used to detect the counter value does not permit punctuation. This change modifies the regular expression used to match the counter value to permit "." and ",".
47 lines
1.7 KiB
JavaScript
47 lines
1.7 KiB
JavaScript
import helpers from './helpers';
|
|
|
|
const { linkIsInternal, getCounterValue } = helpers;
|
|
|
|
const internalUrl = 'https://medium.com/';
|
|
const internalUrlSubPath = 'topic/technology';
|
|
const externalUrl = 'https://www.wikipedia.org/wiki/Electron';
|
|
const wildcardRegex = /.*/;
|
|
|
|
test('the original url should be internal', () => {
|
|
expect(linkIsInternal(internalUrl, internalUrl, undefined)).toEqual(true);
|
|
});
|
|
|
|
test('sub-paths of the original url should be internal', () => {
|
|
expect(
|
|
linkIsInternal(internalUrl, internalUrl + internalUrlSubPath, undefined),
|
|
).toEqual(true);
|
|
});
|
|
|
|
test("'about:blank' should be internal", () => {
|
|
expect(linkIsInternal(internalUrl, 'about:blank', undefined)).toEqual(true);
|
|
});
|
|
|
|
test('urls from different sites should not be internal', () => {
|
|
expect(linkIsInternal(internalUrl, externalUrl, undefined)).toEqual(false);
|
|
});
|
|
|
|
test('all urls should be internal with wildcard regex', () => {
|
|
expect(linkIsInternal(internalUrl, externalUrl, wildcardRegex)).toEqual(true);
|
|
});
|
|
|
|
const smallCounterTitle = 'Inbox (11) - nobody@example.com - Gmail';
|
|
const largeCounterTitle = 'Inbox (8,756) - nobody@example.com - Gmail';
|
|
const noCounterTitle = 'Inbox - nobody@example.com - Gmail';
|
|
|
|
test('getCounterValue should return undefined for titles without counter numbers', () => {
|
|
expect(getCounterValue(noCounterTitle)).toEqual(undefined);
|
|
});
|
|
|
|
test('getCounterValue should return a string for small counter numbers in the title', () => {
|
|
expect(getCounterValue(smallCounterTitle)).toEqual('11');
|
|
});
|
|
|
|
test('getCounterValue should return a string for large counter numbers in the title', () => {
|
|
expect(getCounterValue(largeCounterTitle)).toEqual('8,756');
|
|
});
|