feat: Add unit tests (#21)

Tests are mostly complete (though some are failing -- to be fixed in the
async/await refactor.

Also refactored, fixed bugs found while testing, and added ability to
type `pf;m` instead of `pf;member`.

---------

Co-authored-by: Aster Fialla <asterfialla@gmail.com>
This commit is contained in:
2026-02-24 12:42:23 -05:00
committed by GitHub
parent 428310dfad
commit 7fead5e3d7
18 changed files with 1774 additions and 883 deletions

View File

@@ -8,11 +8,11 @@ const ih = {};
*
* @async
* @param {string} authorId - The author of the message
* @param {string} attachmentUrl - The attached JSON url.
* @param {string | null} [attachmentUrl] - The attached JSON url.
* @returns {string} A successful addition of all members.
* @throws {Error} When the member exists, or creating a member doesn't work.
*/
ih.pluralKitImport = async function (authorId, attachmentUrl) {
ih.pluralKitImport = async function (authorId, attachmentUrl= null) {
if (!attachmentUrl) {
throw new Error(enums.err.NOT_JSON_FILE);
}
@@ -32,7 +32,7 @@ ih.pluralKitImport = async function (authorId, attachmentUrl) {
errors.push(e.message);
});
}
const aggregatedText = addedMembers.length > 0 ? `Successfully added members: ${addedMembers.join(', ')}` : enums.err.NO_MEMBERS_IMPORTED;
const aggregatedText = addedMembers.length > 0 ? `Successfully added members: ${addedMembers.join(', ')}` : `${enums.err.NO_MEMBERS_IMPORTED}`;
if (errors.length > 0) {
throw new AggregateError(errors, aggregatedText);
}