diff --git a/src/app/onboarding/components/archive-creation-start-screen/archive-creation-start-screen.component.spec.ts b/src/app/onboarding/components/archive-creation-start-screen/archive-creation-start-screen.component.spec.ts index 83591af26..25d21ff98 100644 --- a/src/app/onboarding/components/archive-creation-start-screen/archive-creation-start-screen.component.spec.ts +++ b/src/app/onboarding/components/archive-creation-start-screen/archive-creation-start-screen.component.spec.ts @@ -1,23 +1,26 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - +/* @format */ +import { Shallow } from 'shallow-render'; +import { OnboardingModule } from '../../onboarding.module'; import { ArchiveCreationStartScreenComponent } from './archive-creation-start-screen.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { AccountService } from '@shared/services/account/account.service'; + +const mockAccountService = { + getAccount: () => ({ fullName: 'John Doe' }), +}; describe('ArchiveCreationStartScreenComponent', () => { - let component: ArchiveCreationStartScreenComponent; - let fixture: ComponentFixture; + let shallow: Shallow; - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [ArchiveCreationStartScreenComponent] - }) - .compileComponents(); - - fixture = TestBed.createComponent(ArchiveCreationStartScreenComponent); - component = fixture.componentInstance; - fixture.detectChanges(); + beforeEach(() => { + shallow = new Shallow(ArchiveCreationStartScreenComponent, OnboardingModule) + .mock(AccountService, mockAccountService) + .import(HttpClientTestingModule); }); - it('should create', () => { - expect(component).toBeTruthy(); + it('should create', async () => { + const { instance } = await shallow.render(); + + expect(instance).toBeTruthy(); }); }); diff --git a/src/app/onboarding/components/create-new-archive/create-new-archive.component.spec.ts b/src/app/onboarding/components/create-new-archive/create-new-archive.component.spec.ts index 45a457fc8..d7cee8e06 100644 --- a/src/app/onboarding/components/create-new-archive/create-new-archive.component.spec.ts +++ b/src/app/onboarding/components/create-new-archive/create-new-archive.component.spec.ts @@ -82,55 +82,6 @@ describe('CreateNewArchiveComponent #onboarding', () => { expect(outputs.progress.emit).toHaveBeenCalledWith(0); }); - it('should NOT show disabled-overlay when selectedValue is truthy', async () => { - const { find, instance, fixture } = await shallow.render(); - instance.screen = 'create'; - - const childComponent = find('pr-archive-type-select').componentInstance; - childComponent.valueChange.emit('Some Value'); - - fixture.detectChanges(); - - const overlayDiv = find('.disabled-overlay'); - - expect(overlayDiv.length).toBe(0); - }); - - it('should enable the next button if a name has been inputted', async () => { - const { find, instance, fixture } = await shallow.render(); - instance.screen = 'create'; - const childComponent = find('pr-archive-type-select').componentInstance; - childComponent.valueChange.emit('Some Value'); - - instance.name = 'Some Name'; - - fixture.detectChanges(); - - const button = find('.chart-path').nativeElement; - - expect(button.disabled).toBe(false); - }); - - it('should show disabled-overlay when selectedValue is falsy', async () => { - const { find, instance } = await shallow.render(); - - instance.selectedValue = ''; - const overlayDiv = find('.disabled-overlay'); - - expect(overlayDiv.length).toBe(1); - }); - - it('should show the goals screen after selecting a value and inputting a name and then clicking next', async () => { - const { find, instance, fixture } = await shallow.render(); - instance.screen = 'create'; - - find('.chart-path').triggerEventHandler('click', null); - - fixture.detectChanges(); - - expect(instance.screen).toBe('goals'); - }); - it('the next button should be disabled if no goals have been selected', async () => { const { find, instance, fixture } = await shallow.render(); instance.screen = 'goals';