};
- it('GET /list -- chatrooms available', async () => {
-
- await provider
- .addInteraction()
- .given('there are 10 shards')
- .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', (builder) => {
- builder.headers({
- Accept: Matchers.like('application/json'),
- });
- })
- .willRespondWith(200, (builder) => {
- builder.headers({ 'Content-Type': 'application/json' });
- builder.jsonBody(Matchers.eachLike(EXAMPLE_CHATROOM));
- })
- .executeTest(async (mockserver) => {
- await TestBed.configureTestingModule({
- providers: [
- ChatroomService,
- {provide: APP_PROPS, useValue: {backendUri: mockserver.url + '/'}},
- provideHttpClient(),
- ]
- });
-
- const service = TestBed.inject(ChatroomService);
- const chatrooms = await lastValueFrom(service.getChatrooms());
-
- expect(chatrooms).toContainEqual(EXAMPLE_CHATROOM);
- });
- });
-
- it('GET /list -- no chatrooms available', async () => {
-
- await provider
- .addInteraction()
- .given('there are 10 shards')
- .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', (builder) => {
- builder.headers({
- Accept: Matchers.like('application/json'),
- });
- })
- .willRespondWith(200, (builder) => {
- builder.headers({ 'Content-Type': 'application/json' });
- builder.jsonBody([]);
- })
- .executeTest(async (mockserver) => {
- await TestBed.configureTestingModule({
- providers: [
- ChatroomService,
- {provide: APP_PROPS, useValue: {backendUri: mockserver.url + '/'}},
- provideHttpClient(),
- ]
- });
-
- const service = TestBed.inject(ChatroomService);
- const chatrooms = await lastValueFrom(service.getChatrooms());
-
- expect(chatrooms).toHaveLength(0);
- });
- });
-
it('GET /{CHATROOM-ID} -- existing chatroom, responsible shard', async () => {
await provider