Skip to content

Commit

Permalink
Support timezones
Browse files Browse the repository at this point in the history
  • Loading branch information
cressie176 committed Dec 26, 2024
1 parent 84024c6 commit f5b1a4b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ export default class GitHubDriver {
}

#validateLabels(labels) {
const maxLength = 50;
labels.forEach((label) => {
if (label.length > 51) throw new Error(`Label '${label}' is longer than the GitHub max length of 51 characters`);
if (label.length > maxLength) throw new Error(`Label '${label}' is longer than the GitHub max length of ${maxLength} characters`);
});
}
}
10 changes: 5 additions & 5 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,33 +85,33 @@ describe('driver', () => {
eq(labels[3], 'l2');
});

it('should reject reminders with labels greater than 51 characters', async (t) => {
it('should reject reminders with labels greater than 50 characters', async (t) => {
const repository = { owner: 'acuminous', name: 'knuff-github-driver' };
const reminder = {
id: `test-${crypto.randomBytes(10).toString('hex')}`,
title: t.name,
body: 'the body',
labels: ['123456789 123456789 123456789 123456789 123456789 12'],
labels: ['123456789 123456789 123456789 123456789 123456789 1'],
date: new Date('2024-12-25'),
};

await rejects(() => driver.createReminder(repository, reminder), (error) => {
eq(error.message, "Label '123456789 123456789 123456789 123456789 123456789 12' is longer than the GitHub max length of 51 characters");
eq(error.message, "Label '123456789 123456789 123456789 123456789 123456789 1' is longer than the GitHub max length of 50 characters");
return true;
});
});

it('should reject reminders with an id greater than 46 characters', async (t) => {
const repository = { owner: 'acuminous', name: 'knuff-github-driver' };
const reminder = {
id: '123456789 123456789 123456789 123456789 123456',
id: '123456789 123456789 123456789 123456789 12345',
title: t.name,
body: 'the body',
date: new Date('2024-12-25'),
};

await rejects(() => driver.createReminder(repository, reminder), (error) => {
eq(error.message, "Label 'knuff:123456789 123456789 123456789 123456789 123456' is longer than the GitHub max length of 51 characters");
eq(error.message, "Label 'knuff:123456789 123456789 123456789 123456789 12345' is longer than the GitHub max length of 50 characters");
return true;
});
});
Expand Down

0 comments on commit f5b1a4b

Please sign in to comment.