Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add well known symbol method #247

Merged
merged 5 commits into from
Oct 18, 2023
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
7 changes: 7 additions & 0 deletions src/CalendarDate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ export class CalendarDate {
*/
readonly weekday!: number;

/**
* Customizes the default string description for instances of `CalendarDate`.
*/
get [Symbol.toStringTag]() {
return 'CalendarDate';
}

/**
* Throws an Error for invalid inputs.
*
Expand Down
8 changes: 8 additions & 0 deletions test/CalendarDate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1192,4 +1192,12 @@ describe('CalendarDate', () => {
);
});
});

describe('Test of custom string description', () => {
test('the default string description of CalendarDate should be CalendarDate', () => {
const dateInstance = new CalendarDate('2021-01-01');
const tag = Object.prototype.toString.call(dateInstance);
expect(tag).toBe('[object CalendarDate]');
});
});
});