-
Notifications
You must be signed in to change notification settings - Fork 40
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 #487 from aranaravi/develop
Removed the update demographic url
- Loading branch information
Showing
8 changed files
with
54 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { TestBed, async } from '@angular/core/testing'; | ||
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; | ||
import { AppConfigService } from './app-config.service'; | ||
|
||
describe('AppConfigService', () => { | ||
let service: AppConfigService; | ||
let httpTestingController: HttpTestingController; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [HttpClientTestingModule], | ||
providers: [AppConfigService], | ||
}); | ||
service = TestBed.get(AppConfigService); | ||
httpTestingController = TestBed.get(HttpTestingController); | ||
}); | ||
|
||
afterEach(() => { | ||
httpTestingController.verify(); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
|
||
it('should load app config from JSON file', async(() => { | ||
const mockResponse = { | ||
baseUrl: 'https://example.com', | ||
// ... other properties | ||
}; | ||
|
||
service.loadAppConfig(); | ||
|
||
const req = httpTestingController.expectOne('./assets/config.json'); | ||
expect(req.request.method).toBe('GET'); | ||
req.flush(mockResponse); | ||
|
||
expect(service.getConfig()).toEqual(mockResponse); | ||
})); | ||
|
||
it('should handle HTTP error when loading app config', async(() => { | ||
service.loadAppConfig(); | ||
|
||
const req = httpTestingController.expectOne('./assets/config.json'); | ||
expect(req.request.method).toBe('GET'); | ||
req.error(new ErrorEvent('network error')); | ||
|
||
// Handle the error as needed, e.g., by logging it. | ||
spyOn(console, 'error'); | ||
expect(console.error).toHaveBeenCalled(); | ||
})); | ||
|
||
// Add more test cases as needed for other scenarios and error handling | ||
}); |
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
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
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
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