diff --git a/src/components/bulk-email-tool/bulk-email-task-manager/test/BulkEmailPendingTasksAlert.test.jsx b/src/components/bulk-email-tool/bulk-email-task-manager/test/BulkEmailPendingTasksAlert.test.jsx new file mode 100644 index 0000000..50af805 --- /dev/null +++ b/src/components/bulk-email-tool/bulk-email-task-manager/test/BulkEmailPendingTasksAlert.test.jsx @@ -0,0 +1,33 @@ +import React from 'react'; + +import BulkEmailPendingTasksAlert from '../BulkEmailPendingTasksAlert'; +import { + initializeMockApp, render, screen, +} from '../../../../setupTest'; + +describe('Testing BulkEmailPendingTasksAlert Component', () => { + beforeAll(async () => { + await initializeMockApp(); + }); + + test('Render without Public path', async () => { + render(); + + const linkEl = await screen.findByText('Course Info'); + expect(linkEl.href).toEqual('http://localhost:18000/courses/test-course-id/instructor#view-course-info'); + }); + + test('Render with Public path', async () => { + Object.defineProperty(window, 'location', { + get() { + return { pathname: '/communications/courses/test-course-id/bulk-email' }; + }, + }); + + render(); + + const linkEl = await screen.findByText('Course Info'); + expect(linkEl.href).toEqual('http://localhost:18000/courses/test-course-id/instructor#view-course-info'); + expect(window.location.pathname).toEqual('/communications/courses/test-course-id/bulk-email'); + }); +}); diff --git a/src/components/navigation-tabs/BackToInstructor.test.jsx b/src/components/navigation-tabs/BackToInstructor.test.jsx new file mode 100644 index 0000000..ab439bb --- /dev/null +++ b/src/components/navigation-tabs/BackToInstructor.test.jsx @@ -0,0 +1,33 @@ +import React from 'react'; + +import BackToInstructor from './BackToInstructor'; +import { + initializeMockApp, render, screen, +} from '../../setupTest'; + +describe('Testing BackToInstructor Component', () => { + beforeAll(async () => { + await initializeMockApp(); + }); + + test('Render without Public path', async () => { + render(); + + const linkEl = await screen.findByText('Back to Instructor Dashboard'); + expect(linkEl.href).toEqual('http://localhost:18000/courses/test-course-id/instructor#view-course-info'); + }); + + test('Render with Public path', async () => { + Object.defineProperty(window, 'location', { + get() { + return { pathname: '/communications/courses/test-course-id/bulk-email' }; + }, + }); + + render(); + + const linkEl = await screen.findByText('Back to Instructor Dashboard'); + expect(linkEl.href).toEqual('http://localhost:18000/courses/test-course-id/instructor#view-course-info'); + expect(window.location.pathname).toEqual('/communications/courses/test-course-id/bulk-email'); + }); +});