import { Matchers, Pact, SpecificationVersion } from '@pact-foundation/pact';
import { TestBed } from '@angular/core/testing';
-import { HttpErrorResponse, provideHttpClient } from '@angular/common/http';
+import { provideHttpClient } from '@angular/common/http';
import { lastValueFrom } from 'rxjs';
import { ChatroomService } from './chatroom.service';
import { Chatroom } from './chatroom.model';
.given('the server is responsible for shard 2')
.given('chatroom 5c73531c-6fc4-426c-adcb-afc5c140a0f7 exists in shard 2')
.uponReceiving('a request for /list')
- .withRequest('GET', '/list')
+ .withRequest('GET', '/list', (builder) => {
+ builder.headers({
+ Accept: Matchers.like('application/json'),
+ });
+ })
.willRespondWith(200, (builder) => {
builder.headers({ 'Content-Type': 'application/json' });
builder.jsonBody(Matchers.eachLike(EXAMPLE_CHATROOM));
.given('the server is responsible for shard 2')
.given('there are no chatrooms available at all in shard 2')
.uponReceiving('a request for /list')
- .withRequest('GET', '/list')
+ .withRequest('GET', '/list', (builder) => {
+ builder.headers({
+ Accept: Matchers.like('application/json'),
+ });
+ })
.willRespondWith(200, (builder) => {
builder.headers({ 'Content-Type': 'application/json' });
builder.jsonBody([]);
.given('chatroom 5c73531c-6fc4-426c-adcb-afc5c140a0f7 exists in shard 2')
.uponReceiving('a request for /5c73531c-6fc4-426c-adcb-afc5c140a0f7')
.withRequest('GET', '/5c73531c-6fc4-426c-adcb-afc5c140a0f7', (builder) => {
- builder.headers({ 'X-Shard': 2 })
+ builder.headers({
+ Accept: Matchers.like('application/json'),
+ 'X-Shard': 2,
+ });
})
.willRespondWith(200, (builder) => {
builder.headers({ 'Content-Type': 'application/json' });
.given('chatroom 7f59ec77-832e-4a17-8d22-55ef46242c17 does not exists in shard 2')
.uponReceiving('a request for /7f59ec77-832e-4a17-8d22-55ef46242c17')
.withRequest('GET', '/7f59ec77-832e-4a17-8d22-55ef46242c17', (builder) => {
- builder.headers({ 'X-Shard': 2 })
+ builder.headers({
+ Accept: Matchers.like('application/json'),
+ 'X-Shard': 2,
+ });
})
.willRespondWith(404)
.executeTest(async (mockserver) => {