mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.4 KiB
48 lines
1.4 KiB
/*
|
|
* Squidex Headless CMS
|
|
*
|
|
* @license
|
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
|
|
*/
|
|
|
|
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
|
|
import { inject, TestBed } from '@angular/core/testing';
|
|
|
|
import { ApiUrlConfig, GraphQlService } from '@app/shared/internal';
|
|
|
|
describe('GraphQlService', () => {
|
|
beforeEach(() => {
|
|
TestBed.configureTestingModule({
|
|
imports: [
|
|
HttpClientTestingModule
|
|
],
|
|
providers: [
|
|
GraphQlService,
|
|
{ provide: ApiUrlConfig, useValue: new ApiUrlConfig('http://service/p/') }
|
|
]
|
|
});
|
|
});
|
|
|
|
afterEach(inject([HttpTestingController], (httpMock: HttpTestingController) => {
|
|
httpMock.verify();
|
|
}));
|
|
|
|
it('should make get request to get history events',
|
|
inject([GraphQlService, HttpTestingController], (graphQlService: GraphQlService, httpMock: HttpTestingController) => {
|
|
|
|
let graphQlResult: any = null;
|
|
|
|
graphQlService.query('my-app', {}).subscribe(result => {
|
|
graphQlResult = result;
|
|
});
|
|
|
|
const req = httpMock.expectOne('http://service/p/api/content/my-app/graphql');
|
|
|
|
expect(req.request.method).toEqual('POST');
|
|
expect(req.request.headers.get('If-Match')).toBeNull();
|
|
|
|
req.flush({ result: true });
|
|
|
|
expect(graphQlResult).toEqual({ result: true });
|
|
}));
|
|
});
|