-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2197 from IDEMSInternational/test/task-service
Test: task service tests; minimal test infrastructure for other services
- Loading branch information
Showing
12 changed files
with
382 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { CampaignService } from "./campaign.service"; | ||
|
||
export class MockCampaignService implements Partial<CampaignService> { | ||
public async ready(timeoutValue?: number): Promise<boolean> { | ||
return true; | ||
} | ||
// TODO - implement further methods | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/app/shared/components/template/services/template-field.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { HttpClientTestingModule } from "@angular/common/http/testing"; | ||
import { TestBed } from "@angular/core/testing"; | ||
import { TemplateFieldService } from "./template-field.service"; | ||
import type { PromiseExtended } from "dexie"; | ||
import { booleanStringToBoolean } from "src/app/shared/utils"; | ||
|
||
/** Mock calls for field values from the template field service to return test data */ | ||
export class MockTemplateFieldService implements Partial<TemplateFieldService> { | ||
mockFields: any; | ||
|
||
// allow additional specs implementing service to provide their own fields | ||
constructor(mockFields: any = {}) { | ||
this.mockFields = mockFields; | ||
} | ||
public getField(key: string) { | ||
return booleanStringToBoolean(this.mockFields[key]); | ||
} | ||
public setField(key: string, value: string) { | ||
this.mockFields[key] = value; | ||
return Promise.resolve("_") as PromiseExtended; | ||
} | ||
public async ready(timeoutValue?: number): Promise<boolean> { | ||
return true; | ||
} | ||
} | ||
|
||
describe("TemplateFieldService", () => { | ||
let service: TemplateFieldService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [HttpClientTestingModule], | ||
}); | ||
service = TestBed.inject(TemplateFieldService); | ||
}); | ||
|
||
it("should be created", () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
src/app/shared/components/template/services/template-translate.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { TestBed } from "@angular/core/testing"; | ||
import { TemplateTranslateService } from "./template-translate.service"; | ||
|
||
/** Mock calls for field values from the template field service to return test data */ | ||
export class MockTemplateTranslateService implements Partial<TemplateTranslateService> { | ||
public translateValue(value: string) { | ||
return value; | ||
} | ||
|
||
public async ready(timeoutValue?: number): Promise<boolean> { | ||
return true; | ||
} | ||
} | ||
|
||
describe("TaskService", () => { | ||
let service: TemplateTranslateService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = TestBed.inject(TemplateTranslateService); | ||
}); | ||
|
||
it("should be created", () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
src/app/shared/services/app-config/app-config.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.