Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Contributions via Pull Request are welcome. Keep changes to porting the C# sourc
[gitghub-codeql-status]: https://github.com/sillsdev/scripture/actions/workflows/codeql-analysis.yml/badge.svg
[gitghub-codeql-url]: https://github.com/sillsdev/scripture/actions/workflows/codeql-analysis.yml
[github-codecov-status]: https://codecov.io/gh/sillsdev/scripture/branch/main/graph/badge.svg?token=N51WM8PR2E
[github-codecov-url]: :https://codecov.io/gh/sillsdev/scripture
[github-codecov-url]: https://codecov.io/gh/sillsdev/scripture
[github-tag-image]: https://img.shields.io/github/tag/sillsdev/scripture.svg?label=version
[github-tag-url]: https://github.com/sillsdev/scripture/releases/latest
[github-license]: https://github.com/sillsdev/scripture/blob/main/LICENSE
Expand Down
25 changes: 25 additions & 0 deletions src/verse-ref.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,29 @@ describe('VerseRef', () => {
expect(vref.versification).toEqual(ScrVers.Septuagint);
});
});

// Tests that don't exist in the C#.
describe('Extra (TS-only tests)', () => {
it('should convert to empty string', () => {
const vref = new VerseRef();
expect(vref.toString()).toEqual('');
});

it('should convert to string', () => {
const vref = new VerseRef(1, 2, 3, ScrVers.Septuagint);
expect(vref.toString()).toEqual('GEN 2:3');
});

it('should confirm when refs are equal', () => {
const vref = new VerseRef(1, 2, 3, ScrVers.Septuagint);
const vrefClone = vref.clone();
expect(vref.equals(vrefClone)).toBe(true);
});

it('should confirm when refs are not equal', () => {
const vref = new VerseRef(1, 2, 3, ScrVers.Septuagint);
const vrefNotEqual = new VerseRef(1, 20, 3, ScrVers.Septuagint);
expect(vref.equals(vrefNotEqual)).toBe(false);
});
});
});
7 changes: 4 additions & 3 deletions src/verse-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,15 +469,16 @@ export class VerseRef {

/**
* Compares this `VerseRef` with supplied one.
* @param verseRef - `VerseRef` to compare this one to.
* @param verseRef - object to compare this one to.
* @returns `true` if this `VerseRef` is equal to the supplied on, `false` otherwise.
*/
equals(verseRef: VerseRef): boolean {
equals(verseRef: object): boolean {
if (!(verseRef instanceof VerseRef)) return false;
return (
verseRef._bookNum === this._bookNum &&
verseRef._chapterNum === this._chapterNum &&
verseRef._verseNum === this._verseNum &&
verseRef._verse === this._verse &&
verseRef.verse === this.verse &&
verseRef.versification != null &&
this.versification != null &&
verseRef.versification.equals(this.versification)
Expand Down