-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK][NRPTI-1223] add two tests for work around act name changes (#1225
) * updated some comments with some copy/paste errors and added a boilerplate test for acts.service * added legislation list detail comp test to show legislation data being shown in component * modified parseTitleFromXML, improved error handling and made function public * added test for parseTitleFromXML, includes positive and negative cases * linting fix * reformatted legislation list detail test to make the test more readable * further lint fix
- Loading branch information
1 parent
1ec544c
commit d44c763
Showing
5 changed files
with
64 additions
and
13 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
18 changes: 18 additions & 0 deletions
18
angular/projects/public-nrpti/src/app/services/acts.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,18 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { HttpClientTestingModule } from '@angular/common/http/testing'; | ||
import { ActService } from './acts.service'; | ||
import { ConfigService } from 'nrpti-angular-components'; | ||
|
||
describe('ApiService', () => { | ||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
providers: [ActService, ConfigService], | ||
imports: [HttpClientTestingModule] | ||
}); | ||
}); | ||
|
||
it('should be created', () => { | ||
const service = TestBed.get(ActService); | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
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
17 changes: 17 additions & 0 deletions
17
api/src/tests/controllers/acts-regulations-controller.test.js
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,17 @@ | ||
const actsRegulationsController = require('../../controllers/acts-regulations-controller'); | ||
|
||
describe('parseTitleFromXML', () => { | ||
const testTitle = 'Act Name'; | ||
const testXMLWithActName = '<act:act><act:title>' + testTitle + '</act:title></act:act>'; | ||
const testXMLWithoutActName = '<act:act></act:act>'; | ||
|
||
it('returns null if act:title field is not found', () => { | ||
const result = actsRegulationsController.parseTitleFromXML(testXMLWithoutActName); | ||
expect(result).toEqual(null); | ||
}); | ||
|
||
it('returns Act title if act:title field is present', () => { | ||
const result = actsRegulationsController.parseTitleFromXML(testXMLWithActName); | ||
expect(result).toEqual(testTitle); | ||
}); | ||
}); |