diff --git a/app/scripts/modules/core/src/api/ApiService.spec.ts b/app/scripts/modules/core/src/api/ApiService.spec.ts index 9ccb07173df..959cb774763 100644 --- a/app/scripts/modules/core/src/api/ApiService.spec.ts +++ b/app/scripts/modules/core/src/api/ApiService.spec.ts @@ -70,6 +70,22 @@ describe('API Service', function() { expect(rejected).toBe(true); }); + it('application/foo+json is fine', () => { + spyOn(AuthenticationInitializer, 'reauthenticateUser').and.callFake(noop); + $httpBackend + .expectGET(`${baseUrl}/bad`) + .respond(200, '{"good":"job"}', { 'content-type': 'application/foo+json' }); + + let rejected = false; + API.one('bad') + .get() + .then(noop, () => (rejected = true)); + + $httpBackend.flush(); + expect((AuthenticationInitializer.reauthenticateUser as Spy).calls.count()).toBe(0); + expect(rejected).toBe(false); + }); + it('string responses starting with { const contentType = result.headers('content-type'); if (contentType) { - const isJson = contentType.includes('application/json'); + const isJson = contentType.match(/application\/(.+\+)?json/); // e.g application/json, application/hal+json const isZeroLengthHtml = contentType.includes('text/html') && result.data === ''; const isZeroLengthText = contentType.includes('text/plain') && result.data === ''; if (!(isJson || isZeroLengthHtml || isZeroLengthText)) {