fix(common): don't convert null to a string when flushing a mock request (#21417)
A bug in TestRequest caused null response bodies to be stringified. This change causes null to be treated faithfully. Fixes #20744 PR Close #21417
This commit is contained in:
27
packages/common/http/testing/test/request_spec.ts
Normal file
27
packages/common/http/testing/test/request_spec.ts
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ddescribe, describe, iit, it} from '@angular/core/testing/src/testing_internal';
|
||||
|
||||
import {HttpClient} from '../../src/client';
|
||||
import {HttpClientTestingBackend} from '../src/backend';
|
||||
|
||||
describe('HttpClient TestRequest', () => {
|
||||
it('accepts a null body', () => {
|
||||
const mock = new HttpClientTestingBackend();
|
||||
const client = new HttpClient(mock);
|
||||
|
||||
let resp: any;
|
||||
client.post('/some-url', {test: 'test'}).subscribe(body => { resp = body; });
|
||||
|
||||
const req = mock.expectOne('/some-url');
|
||||
req.flush(null);
|
||||
|
||||
expect(resp).toBeNull();
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user