Fix style, add simple permission utils tests
This commit is contained in:
parent
21e3cd2f95
commit
a33d651d01
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue