Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: TTL-888 added test for searching tech with special characters
  • Loading branch information
mmaquina committed May 24, 2023
commit ce0553ceb71ed846f237a79031d2b5c38a26ec1e
17 changes: 16 additions & 1 deletion src/app/modules/shared/services/technology.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { Technology } from '../../shared/models';
import { TechnologyService } from './technology.service';
import { STACK_EXCHANGE_ID, STACK_EXCHANGE_ACCESS_TOKEN } from '../../../../environments/environment';

describe('TechnologyService', () => {
fdescribe('TechnologyService', () => {
let service: TechnologyService;
let httpMock: HttpTestingController;

const technologyList: Technology = { items: [{ name: 'java' }, { name: 'javascript' }] };
const technologyListWithSpecialChar: Technology = { items: [{ name: 'c#' }, { name: 'c#-2.0' }] };

beforeEach(() => {
TestBed.configureTestingModule({
Expand Down Expand Up @@ -42,4 +43,18 @@ describe('TechnologyService', () => {
expect(getTechnologiesRequest.request.method).toBe('GET');
getTechnologiesRequest.flush(technologyList);
});

it('technologies with special characters are read using GET from url', () => {
const technologyFoundSize = technologyListWithSpecialChar.items.length;
const technologyName = 'c#';
service.getTechnologies(technologyName).subscribe((technologyInResponse) => {
expect(technologyInResponse.items.length).toBe(technologyFoundSize);
});
const getTechnologiesRequest = httpMock.expectOne(
`${service.baseUrl}&inname=${encodeURIComponent(technologyName)}&site=stackoverflow&key=${STACK_EXCHANGE_ID}&access_token=${STACK_EXCHANGE_ACCESS_TOKEN}`
);
expect(getTechnologiesRequest.request.method).toBe('GET');
getTechnologiesRequest.flush(technologyListWithSpecialChar);
});

});