Fix style, add simple permission utils tests

This commit is contained in:
Szymon Uglis 2021-03-04 01:11:47 +01:00
parent 21e3cd2f95
commit a33d651d01
No known key found for this signature in database
GPG key ID: 112376C5BEE91FE2
3 changed files with 20 additions and 4 deletions

View file

@ -2,13 +2,11 @@ part of nyxx;
/// A utility to run ._build() on internal functions
class BuilderUtility {
/// Build the data from an [EmbedBuilder]
static Map<String, dynamic> buildRawEmbed(EmbedBuilder embed) =>
embed._build();
/// Build the data from [AllowedMentions]
static Map<String, dynamic> buildRawAllowedMentions(
AllowedMentions mentions) =>
static Map<String, dynamic> buildRawAllowedMentions(AllowedMentions mentions) =>
mentions._build();
}

View file

@ -26,6 +26,10 @@ class EmbedAuthorBuilder implements Builder {
throw EmbedBuilderArgumentException._new("Author name is too long. (256 characters limit)");
}
return <String, dynamic>{ "name": name, if (url != null) "url": url, if (iconUrl != null) "icon_url": iconUrl};
return <String, dynamic> {
"name": name,
if (url != null) "url": url,
if (iconUrl != null) "icon_url": iconUrl
};
}
}

View file

@ -88,4 +88,18 @@ void main() {
]));
});
});
group("Permission utils", () {
test("PermissionsUtils.apply returns valid int", () {
final appliedPermissions = PermissionsUtils.apply(0x01, 0x10, 0x01);
expect(appliedPermissions, 0x10);
});
test("PermissionsUtils.isApplied returns valid result", () {
const permissionInt = 0x01;
expect(PermissionsUtils.isApplied(permissionInt, 0x01), true);
expect(PermissionsUtils.isApplied(permissionInt, 0x10), false);
});
});
}