Skip to content

Commit

Permalink
updating tests, updating verbs
Browse files Browse the repository at this point in the history
  • Loading branch information
CameronThornton committed Jun 29, 2024
1 parent 2b4236a commit adc4992
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
26 changes: 13 additions & 13 deletions calavera/src/app/features/trivia/trivia-edit.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ describe('TriviaComponent', () => {
let router: Router;

const question: TriviaQuestion =
{
id: 1,
category: "general",
question: "When?",
answer: "Now",
isEnabled: true,
createdDate: new Date(),
updatedDate: new Date()
};
{
id: 1,
category: "general",
question: "When?",
answer: "Now",
isEnabled: true,
createdDate: new Date(),
updatedDate: new Date()
};

beforeEach(() => {
httpSpy = jasmine.createSpyObj('HttpClient', ['get', 'post']);
httpSpy = jasmine.createSpyObj('HttpClient', ['get', 'put']);

TestBed.configureTestingModule({
imports: [
Expand Down Expand Up @@ -51,7 +51,7 @@ describe('TriviaComponent', () => {
const fixture = TestBed.createComponent(TriviaEditComponent);
const triviaEditComponent = fixture.componentInstance;
triviaEditComponent.ngOnInit();

expect(triviaEditComponent.triviaQuestion).toEqual(question);
});

Expand All @@ -66,9 +66,9 @@ describe('TriviaComponent', () => {
createdDate: new Date(),
updatedDate: new Date()
};

httpSpy.get.and.returnValue(of(question))
httpSpy.post.and.returnValue(of(updatedQuestion))
httpSpy.put.and.returnValue(of(updatedQuestion))

const fixture = TestBed.createComponent(TriviaEditComponent);
const triviaEditComponent = fixture.componentInstance;
Expand Down
2 changes: 1 addition & 1 deletion calavera/src/app/features/trivia/trivia.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('TriviaComponent', () => {
let router: Router;

beforeEach(() => {
httpSpy = jasmine.createSpyObj('HttpClient', ['get', 'post']);
httpSpy = jasmine.createSpyObj('HttpClient', ['get', 'put']);

TestBed.configureTestingModule({
imports: [
Expand Down
4 changes: 2 additions & 2 deletions calavera/src/app/services/trivia.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('TriviaService', () => {
httpMock.verify();
});

it('save should post question', () => {
it('save should put question', () => {

const question: TriviaQuestion = {
id: 1,
Expand All @@ -95,7 +95,7 @@ describe('TriviaService', () => {
});

const req = httpMock.expectOne(environment.slimerUrl + '/api/trivia');
expect(req.request.method).toEqual("POST");
expect(req.request.method).toEqual("PUT");
req.flush(question);

httpMock.verify();
Expand Down
18 changes: 9 additions & 9 deletions calavera/src/app/services/trivia.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ export class TriviaService {

getTrivia() {
return this.http.get<TriviaQuestion[]>(this.root + "/api/trivia/search")
.pipe(
timeout(10000),
catchError(this.handleError)
)
.pipe(
timeout(10000),
catchError(this.handleError)
)
}

searchTrivia(id: number) {
return this.http.get<TriviaQuestion>(this.root + "/api/trivia/search/" + id)
.pipe(
timeout(10000),
catchError(this.handleError)
)
.pipe(
timeout(10000),
catchError(this.handleError)
)
}

saveTrivia(triviaQuestion: TriviaQuestion) {
return this.http.post<TriviaQuestion>(this.root + "/api/trivia", triviaQuestion)
return this.http.put<TriviaQuestion>(this.root + "/api/trivia", triviaQuestion)
.pipe(
timeout(10000),
catchError(this.handleError)
Expand Down

0 comments on commit adc4992

Please sign in to comment.