Lines Matching refs:t
16 export async function test(t) { argument
19 const describeWithPermissions = shouldSkipTestsRequiringPermissions ? t.xdescribe : t.describe;
21 t.describe('Notifications', () => {
22 t.describe('getDevicePushTokenAsync', () => {
27 t.beforeAll(() => {
33 t.afterAll(() => {
41 t.it('resolves with a string', async () => {
43 t.expect(typeof devicePushToken.data).toBe('string');
49 t.it('resolves with an object', async () => {
51 t.expect(typeof devicePushToken.data).toBe('object');
56 t.it('emits an event with token (or not, if getDevicePushTokenAsync failed)', async () => {
60 t.expect(tokenFromEvent).toEqual(tokenFromMethodCall);
63 t.it('resolves when multiple calls are issued', async () => {
68 t.expect(results[0].data).toBeDefined();
69 t.expect(results[0].data).toBe(results[1].data);
73 const itWithExpoPushToken = ['ios', 'android'].includes(Platform.OS) ? t.it : t.xit;
85 t.expect(expoPushToken.type).toBe('expo');
86 t.expect(typeof expoPushToken.data).toBe('string');
106 ? t.describe
107 : t.xdescribe;
121 t.beforeAll(async () => {
160 t.beforeEach(async () => {
168 t.afterAll(() => {
176 t.it('calls the `handleNotification` callback of the notification handler', async () => {
185 t.expect(notificationToHandle).not.toBeNull();
188 t.it('emits a “notification received” event', async () => {
197 t.expect(receivedEvent).not.toBeNull();
200 t.it('the notification has proper `data` value', async () => {
209 t.expect(receivedEvent.request.content.data.fieldTestedInDataContentsTest).toBe(42);
212 t.describe('if handler responds in time', async () => {
213 t.it(
224 t.expect(handleSuccessEvent).not.toBeNull();
225 t.expect(handleErrorEvent).toBeNull();
231 t.describe('if handler fails to respond in time', async () => {
232 t.beforeAll(() => {
243 t.afterAll(() => {
247 t.it(
258 t.expect(handleErrorEvent).not.toBeNull();
259 t.expect(typeof handleErrorEvent[0]).toBe('string');
260 t.expect(handleSuccessEvent).toBeNull();
267 t.describe('getPermissionsAsync', () => {
268 t.it('resolves with an object', async () => {
270 t.expect(permissions).toBeDefined();
271 t.expect(typeof permissions).toBe('object');
276 t.it('resolves without any arguments', async () => {
278 t.expect(permissions).toBeDefined();
279 t.expect(typeof permissions).toBe('object');
282 t.it('resolves with specific permissions requested', async () => {
289 t.expect(permissions).toBeDefined();
290 t.expect(typeof permissions).toBe('object');
291 t.expect(typeof permissions.status).toBe('string');
295 t.describe('presentNotificationAsync', () => {
296 t.it('presents a simple notification', async () => {
305 t.it('presents a notification with attachments', async () => {
316 t.describe('Notification channels', () => {
325 t.describe('getNotificationChannelAsync()', () => {
326 t.it('returns null if there is no such channel', async () => {
329 t.expect(channel).toBe(null);
334 t.it('returns an object if there is such channel', async () => {
336 t.expect(channel).toBeDefined();
341 t.describe('getNotificationChannelsAsync()', () => {
342 t.it('returns an array', async () => {
344 t.expect(channels).toEqual(t.jasmine.any(Array));
349 t.it('contains the fallback channel', async () => {
351 t.expect(channels).toContain(
352 t.jasmine.objectContaining({
362 t.describe('setNotificationChannelAsync()', () => {
363 t.afterEach(async () => {
368 t.it('returns the modified channel', async () => {
373 t.expect(channel).toEqual(
374 t.jasmine.objectContaining({ ...testChannel, id: testChannelId })
378 t.it('creates a channel', async () => {
380 const channelSpec = t.jasmine.objectContaining({ ...testChannel, id: testChannelId });
381 t.expect(preChannels).not.toContain(channelSpec);
384 t.expect(postChannels).toContain(channelSpec);
385 t.expect(postChannels.length).toBeGreaterThan(preChannels.length);
388 t.it('sets custom properties', async () => {
411 t.expect(channel).toEqual(t.jasmine.objectContaining({ ...spec, id: testChannelId }));
414 t.it('assigns a channel to a group', async () => {
422 t.expect(channel.groupId).toBe(groupId);
424 t.expect(group.channels).toContain(t.jasmine.objectContaining(testChannel));
432 t.it('updates a channel', async () => {
440 t.expect(channels).toContain(
441 t.jasmine.objectContaining({
446 t.expect(channels).not.toContain(
447 t.jasmine.objectContaining({
454 t.it("doesn't throw an error", async () => {
460 t.describe('deleteNotificationChannelAsync()', () => {
462 t.it('deletes a channel', async () => {
464 const channelSpec = t.jasmine.objectContaining({ ...testChannel, id: testChannelId });
465 t.expect(preChannels).not.toContain(channelSpec);
469 t.expect(postChannels).toContain(channelSpec);
470 t.expect(postChannels.length).toBeGreaterThan(preChannels.length);
473 t.it("doesn't throw an error", async () => {
480 t.describe('Notification channel groups', () => {
484 t.describe('getNotificationChannelGroupAsync()', () => {
485 t.it('returns null if there is no such channel group', async () => {
489 t.expect(channelGroup).toBe(null);
493 t.it('returns an object if there is such channel group', async () => {
501 t.expect(channel).toBeDefined();
506 t.describe('getNotificationChannelGroupsAsync()', () => {
508 t.it('returns an array', async () => {
510 t.expect(channels).toEqual(t.jasmine.any(Array));
513 t.it('returns existing channel groups', async () => {
520 t.expect(channels).toContain(channel);
523 t.it("doesn't throw an error", async () => {
529 t.describe('setNotificationChannelGroupsAsync()', () => {
530 t.afterEach(async () => {
535 t.it('returns the modified channel group', async () => {
540 t.expect(group).toEqual(
541 t.jasmine.objectContaining({ ...testChannelGroup, id: testChannelGroupId })
545 t.it('creates a channel group', async () => {
547 const channelGroupSpec = t.jasmine.objectContaining({
551 t.expect(preChannelGroups).not.toContain(channelGroupSpec);
557 t.expect(postChannelGroups).toContain(channelGroupSpec);
558 t.expect(postChannelGroups.length).toBeGreaterThan(preChannelGroups.length);
561 t.it('sets custom properties', async () => {
575 t.expect(channelGroup).toEqual(
576 t.jasmine.objectContaining({ ...groupSpec, id: testChannelGroupId })
580 t.it('updates a channel group', async () => {
588 t.expect(channelGroups).toContain(
589 t.jasmine.objectContaining({
594 t.expect(channelGroups).not.toContain(
595 t.jasmine.objectContaining({
602 t.it("doesn't throw an error", async () => {
612 t.describe('Notification Categories', () => {
659 t.describe('getNotificationCategoriesAsync()', () => {
661 t.beforeAll(async () => {
665 t.afterEach(async () => {
671 t.it('returns an empty array if there are no categories', async () => {
672 t.expect((await Notifications.getNotificationCategoriesAsync()).length).toEqual(
677 t.it('returns an array with the just-created categories', async () => {
688 t.expect((await Notifications.getNotificationCategoriesAsync()).length).toEqual(
694 t.describe('setNotificationCategoriesAsync()', () => {
695 t.afterEach(async () => {
700 t.it('creates a category with one action successfully', async () => {
707 t.expect(testCategory1.identifier).toEqual(resultCategory.identifier);
709 t.expect(action.identifier).toEqual(resultCategory.actions[i].identifier);
710 t.expect(action.buttonTitle).toEqual(resultCategory.actions[i].buttonTitle);
711 t.expect(action.options).toEqual(
712 t.jasmine.objectContaining(resultCategory.actions[i].options)
715 t.expect(testCategory1.options).toEqual(
716 t.jasmine.objectContaining(resultCategory.options)
720 t.it('creates a category with two actions successfully', async () => {
727 t.expect(testCategory2.identifier).toEqual(resultCategory.identifier);
729 t.expect(action.identifier).toEqual(resultCategory.actions[i].identifier);
730 t.expect(action.buttonTitle).toEqual(resultCategory.actions[i].buttonTitle);
731 t.expect(action.options).toEqual(
732 t.jasmine.objectContaining(resultCategory.actions[i].options)
735 t.expect(testCategory2.options).toEqual(
736 t.jasmine.objectContaining(resultCategory.options)
741 t.describe('deleteNotificationCategoriesAsync()', () => {
742 t.afterEach(async () => {
747 t.it('deleting a category that does not exist returns false', async () => {
749 t.expect(
753 t.expect(categoriesAfter.length).toEqual(categoriesBefore.length);
756 t.it('deleting a category that does exist returns true', async () => {
762 t.expect(
767 t.it('returns an array of length 1 after creating 2 categories & deleting 1', async () => {
781 t.expect(categoriesBefore.length - 1).toEqual(categoriesAfter.length);
786 t.describe('getBadgeCountAsync', () => {
787 t.it('resolves with an integer', async () => {
789 t.expect(typeof badgeCount).toBe('number');
793 t.describe('setBadgeCountAsync', () => {
794 t.it('resolves with a boolean', async () => {
797 t.expect(typeof result).toBe('boolean');
800 t.it('sets a retrievable counter (if set succeeds)', async () => {
804 t.expect(badgeCount).toBe(randomCounter);
810 t.it('clears the counter', async () => {
814 t.expect(badgeCount).toBe(clearingCounter);
818 t.describe('getPresentedNotificationsAsync()', () => {
822 t.beforeAll(() => {
833 t.it('resolves with an array containing a displayed notification', async () => {
845 t.expect(displayedNotifications).toContain(
846 t.jasmine.objectContaining({
847 request: t.jasmine.objectContaining({
854 t.it('resolves with an array that does not contain a canceled notification', async () => {
858 t.expect(displayedNotifications).not.toContain(
859 t.jasmine.objectContaining({
860 request: t.jasmine.objectContaining({
869 t.it('includes the foreign persistent notification', async () => {
871 t.expect(displayedNotifications).toContain(
872 t.jasmine.objectContaining({
873 request: t.jasmine.objectContaining({
874 identifier: t.jasmine.stringMatching(
884 t.describe('dismissNotificationAsync()', () => {
885 t.it('resolves for a valid notification ID', async () => {
897 t.it('resolves for an invalid notification ID', async () => {
902 t.describe('dismissAllNotificationsAsync()', () => {
903 t.it('resolves', async () => {
908 t.describe('getAllScheduledNotificationsAsync', () => {
912 t.afterEach(async () => {
916 t.it('resolves with an Array', async () => {
918 t.expect(notifications).toEqual(t.jasmine.arrayContaining([]));
921 t.it('contains a scheduled notification', async () => {
931 t.expect(notifications).toContain(
932 t.jasmine.objectContaining({
934 content: t.jasmine.objectContaining(notification),
935 trigger: t.jasmine.objectContaining({
944 t.it('does not contain a canceled notification', async () => {
955 t.expect(notifications).not.toContain(t.jasmine.objectContaining({ identifier }));
959 t.describe('scheduleNotificationAsync', () => {
969 t.afterEach(async () => {
973 t.it(
976 const notificationReceivedSpy = t.jasmine.createSpy('notificationReceived');
985 t.expect(notificationReceivedSpy).toHaveBeenCalled();
991 t.it(
1004 t.expect(error).toBeDefined();
1009 t.it(
1022 t.expect(error).toBeDefined();
1027 t.it(
1030 const notificationReceivedSpy = t.jasmine.createSpy('notificationReceived');
1039 t.expect(notificationReceivedSpy).toHaveBeenCalled();
1041 t.expect(notificationReceivedSpy).toHaveBeenCalledWith(
1042 t.jasmine.objectContaining({
1043 request: t.jasmine.objectContaining({
1044 content: t.jasmine.objectContaining({
1057 t.it(
1075 t.expect(notificationFromEvent).toBeDefined();
1081 t.it(
1103 t.expect(notificationFromEvent).toBeDefined();
1104 t.expect(notificationFromEvent).toEqual(
1105 t.jasmine.objectContaining({
1106 request: t.jasmine.objectContaining({
1107 content: t.jasmine.objectContaining({
1118 t.it(
1140 t.expect(notificationFromEvent).toBeDefined();
1141 t.expect(notificationFromEvent).toEqual(
1142 t.jasmine.objectContaining({
1143 request: t.jasmine.objectContaining({
1144 content: t.jasmine.objectContaining({
1155 t.it(
1174 t.expect(notificationFromEvent).toBeDefined();
1180 t.it(
1197 t.expect(result[0].trigger).toEqual({
1203 t.expect(result[0].trigger).toEqual({
1221 t.it(
1241 t.expect(result[0].trigger).toEqual({
1247 t.expect(result[0].trigger).toEqual({
1265 t.it(
1284 t.expect(result[0].trigger).toEqual({
1290 t.expect(result[0].trigger).toEqual({
1314 t.it(
1330 t.expect(timesSpyHasBeenCalled).toBeGreaterThan(1);
1338 t.it(
1341 const notificationReceivedSpy = t.jasmine.createSpy('notificationReceived');
1352 t.expect(notificationReceivedSpy).toHaveBeenCalled();
1360 t.describe('getNextTriggerDateAsync', () => {
1362 t.it('generates trigger date for a calendar trigger', async () => {
1364 t.expect(nextDate).not.toBeNull();
1367 t.it('fails to generate trigger date for a calendar trigger', async () => {
1374 t.expect(exception).toBeDefined();
1378 t.it('generates trigger date for a daily trigger', async () => {
1384 t.expect(nextDate).not.toBeNull();
1385 t.expect(new Date(nextDate).getHours()).toBe(9);
1386 t.expect(new Date(nextDate).getMinutes()).toBe(20);
1389 t.it('generates trigger date for a weekly trigger', async () => {
1396 t.expect(nextDateTimestamp).not.toBeNull();
1399 t.expect(nextDate.getDay()).toBe(1);
1400 t.expect(nextDate.getHours()).toBe(9);
1401 t.expect(nextDate.getMinutes()).toBe(20);
1404 t.it('generates trigger date for a yearly trigger', async () => {
1412 t.expect(nextDateTimestamp).not.toBeNull();
1414 t.expect(nextDate.getDate()).toBe(2);
1415 t.expect(nextDate.getMonth()).toBe(6);
1416 t.expect(nextDate.getHours()).toBe(9);
1417 t.expect(nextDate.getMinutes()).toBe(20);
1420 t.it('fails to generate trigger date for the immediate trigger', async () => {
1427 t.expect(exception).toBeDefined();
1431 t.describe('cancelScheduledNotificationAsync', () => {
1435 t.it(
1438 const notificationReceivedSpy = t.jasmine.createSpy('notificationReceived');
1448 t.expect(notificationReceivedSpy).not.toHaveBeenCalled();
1455 t.describe('cancelAllScheduledNotificationsAsync', () => {
1458 t.it(
1461 const notificationReceivedSpy = t.jasmine.createSpy('notificationReceived');
1473 t.expect(notificationReceivedSpy).not.toHaveBeenCalled();
1476 t.expect(scheduledNotifications.length).toEqual(0);
1482 const onlyInteractiveDescribe = isInteractive ? t.describe : t.xdescribe;
1490 t.beforeEach(async () => {
1491 handleNotificationSpy = t.jasmine.createSpy('handleNotificationSpy');
1492 handleSuccessSpy = t.jasmine.createSpy('handleSuccessSpy');
1493 handleErrorSpy = t.jasmine.createSpy('handleErrorSpy').and.callFake((...args) => {
1496 notificationReceivedSpy = t.jasmine.createSpy('notificationReceivedSpy');
1505 t.afterEach(() => {
1517 t.it(
1546 t.expect(notificationWasShown).toBeTruthy();
1547 t.expect(handleNotificationSpy).not.toHaveBeenCalled();
1548 t.expect(handleSuccessSpy).not.toHaveBeenCalled();
1549 t.expect(handleErrorSpy).not.toHaveBeenCalledWith(identifier);
1550 t.expect(notificationReceivedSpy).not.toHaveBeenCalled();
1582 t.beforeEach(async () => {
1593 t.afterEach(() => {
1602 t.it(
1633 t.expect(event).not.toBeNull();
1634 t.expect(event.actionIdentifier).toBe(Notifications.DEFAULT_ACTION_IDENTIFIER);
1635 t.expect(event.notification).toEqual(
1636 t.jasmine.objectContaining({
1637 request: t.jasmine.objectContaining({
1638 content: t.jasmine.objectContaining(notificationSpec),
1642 t.expect(event).toEqual(await Notifications.getLastNotificationResponseAsync());
1661 t.beforeEach(async () => {
1673 t.afterEach(async () => {
1678 t.it(
1700 t.expect(timesSpyHasBeenCalled).toBe(1);
1720 t.beforeEach(async () => {
1732 t.afterEach(async () => {
1737 t.it(
1762 t.expect(timesSpyHasBeenCalled).toBe(1);
1782 t.beforeEach(async () => {
1794 t.afterEach(async () => {
1799 t.it(
1823 t.expect(timesSpyHasBeenCalled).toBe(1);