Skip to content
Snippets Groups Projects
Commit d30245a1 authored by lotte's avatar lotte
Browse files

54472: fixed small test issue

parent 303fc085
Branches
Tags
No related merge requests found
......@@ -23,15 +23,57 @@ describe('IntegrationResponseParsingService', () => {
const uuid = 'd9d30c0c-69b7-4369-8397-ca67c888974d';
const integrationEndpoint = 'https://rest.api/integration/authorities';
const entriesEndpoint = `${integrationEndpoint}/${name}/entries?query=${query}&metadata=${metadata}&uuid=${uuid}`;
let validRequest;
beforeEach(() => {
service = new IntegrationResponseParsingService(EnvConfig, objectCacheService);
});
let validResponse;
describe('parse', () => {
const validRequest = new IntegrationRequest('69f375b5-19f4-4453-8c7a-7dc5c55aafbb', entriesEndpoint);
let invalidResponse1;
let invalidResponse2;
let pageInfo;
let definitions;
function initVars() {
pageInfo = Object.assign(new PageInfo(), { elementsPerPage: 5, totalElements: 5, totalPages: 1, currentPage: 1, self: 'https://rest.api/integration/authorities/type/entries'});
definitions = new PaginatedList(pageInfo,[
Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'One',
id: 'One',
otherInformation: undefined,
value: 'One'
}),
Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Two',
id: 'Two',
otherInformation: undefined,
value: 'Two'
}),
Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Three',
id: 'Three',
otherInformation: undefined,
value: 'Three'
}),
Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Four',
id: 'Four',
otherInformation: undefined,
value: 'Four'
}),
Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Five',
id: 'Five',
otherInformation: undefined,
value: 'Five'
})
]);
validRequest = new IntegrationRequest('69f375b5-19f4-4453-8c7a-7dc5c55aafbb', entriesEndpoint);
const validResponse = {
validResponse = {
payload: {
page: {
number: 0,
......@@ -86,12 +128,12 @@ describe('IntegrationResponseParsingService', () => {
statusCode: '200'
};
const invalidResponse1 = {
invalidResponse1 = {
payload: {},
statusCode: '200'
};
const invalidResponse2 = {
invalidResponse2 = {
payload: {
page: {
number: 0,
......@@ -143,45 +185,13 @@ describe('IntegrationResponseParsingService', () => {
},
statusCode: '200'
};
const pageinfo = Object.assign(new PageInfo(), { elementsPerPage: 5, totalElements: 5, totalPages: 1, currentPage: 1, self: 'https://rest.api/integration/authorities/type/entries'});
const definitions = new PaginatedList(pageinfo,[
Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'One',
id: 'One',
otherInformation: undefined,
value: 'One'
}),
Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Two',
id: 'Two',
otherInformation: undefined,
value: 'Two'
}),
Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Three',
id: 'Three',
otherInformation: undefined,
value: 'Three'
}),
Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Four',
id: 'Four',
otherInformation: undefined,
value: 'Four'
}),
Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Five',
id: 'Five',
otherInformation: undefined,
value: 'Five'
})
]);
}
beforeEach(() => {
initVars();
service = new IntegrationResponseParsingService(EnvConfig, objectCacheService);
});
describe('parse', () => {
it('should return a IntegrationSuccessResponse if data contains a valid endpoint response', () => {
const response = service.parse(validRequest, validResponse);
expect(response.constructor).toBe(IntegrationSuccessResponse);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment