Skip to content

Commit

Permalink
test(contact,newsletter): fix page name assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
griest024 committed Jan 12, 2021
1 parent 3399275 commit 7475eb2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
15 changes: 8 additions & 7 deletions libs/contact/integration-tests/drivers/hubspot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,17 @@ describe('DaffContactHubspotDriver', () => {
describe('when sending', () => {
it('should send a submission', () => {
const forumSubmission = { email: 'test@email.com' };
const mockReq = of(forumSubmission);
contactService.send(forumSubmission).subscribe();
contactService.send(forumSubmission).subscribe((resp) => {
expect(resp).toEqual(forumSubmission);
});
const req = httpMock.expectOne(
`${'https://api.hsforms.com/submissions/v3/integration/submit/123123/123123'}`,
'https://api.hsforms.com/submissions/v3/integration/submit/123123/123123',
);
expect(req.request.body).toEqual({
expect(req.request.body).toEqual(jasmine.objectContaining({
fields: [Object({ name: 'email', value: 'test@email.com' })],
context: Object({ hutk: null, pageUri: '/', pageName: '' }),
});
req.flush(mockReq);
context: Object({ hutk: null, pageUri: '/', pageName: jasmine.any(String) }),
}));
req.flush(forumSubmission);
httpMock.verify();
});

Expand Down
15 changes: 9 additions & 6 deletions libs/newsletter/integration-tests/drivers/hubspot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import { RouterTestingModule } from '@angular/router/testing';
import {
DaffNewsletterHubSpotDriverModule,
DaffNewsletterDriver,
DaffNewsletterServiceInterface
DaffNewsletterServiceInterface,
DaffNewsletterSubmission
} from '@daffodil/newsletter';

describe('DaffNewsletterHubspotDriver', () => {
let newsletterService: DaffNewsletterServiceInterface<any, any>;
let newsletterService: DaffNewsletterServiceInterface<DaffNewsletterSubmission, any>;
let httpMock: HttpTestingController;

beforeEach(() => {
Expand All @@ -27,9 +28,7 @@ describe('DaffNewsletterHubspotDriver', () => {

httpMock = TestBed.inject(HttpTestingController);

newsletterService = TestBed.inject(
DaffNewsletterDriver
);
newsletterService = TestBed.inject(DaffNewsletterDriver);
});

it('should provide an instance of the DaffNewsletterDriver', () => {
Expand All @@ -41,7 +40,11 @@ describe('DaffNewsletterHubspotDriver', () => {
newsletterService.send(newsletterSubmission).subscribe((resp) => {
expect(resp).toEqual(newsletterSubmission);
});
const req = httpMock.expectOne('https://api.hsforms.com/submissions/v3/integration/submit/123123/123123');
const req = httpMock.expectOne('https://api.hsforms.com/submissions/v3/integration/submit/123123/123123');
expect(req.request.body).toEqual(jasmine.objectContaining({
fields: [Object({ name: 'email', value: 'test@email.com' })],
context: Object({ hutk: null, pageUri: '/', pageName: jasmine.any(String) }),
}));
req.flush(newsletterSubmission);
httpMock.verify();
})
Expand Down

0 comments on commit 7475eb2

Please sign in to comment.