Skip to content

Commit

Permalink
tests: use Crux.Structs.create/2 wherever possible
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceEEC committed Apr 3, 2019
1 parent d87e7d8 commit ced8c4e
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion test/structs/attachment_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule Crux.Structs.AttachmentTest do
"https://cdn.discordapp.com/attachments/316880197314019329/440894250004250624/410121532308848640.png",
"width" => 128
}
|> Crux.Structs.Attachment.create()
|> Crux.Structs.create(Crux.Structs.Attachment)

assert attachment == %Crux.Structs.Attachment{
filename: "410121532308848640.png",
Expand Down
2 changes: 1 addition & 1 deletion test/structs/channel_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ defmodule Crux.Structs.ChannelTest do
"type" => 0,
"id" => "250372608284033025"
}
|> Crux.Structs.Channel.create()
|> Crux.Structs.create(Crux.Structs.Channel)

assert channel === %Crux.Structs.Channel{
guild_id: 243_175_181_885_898_762,
Expand Down
4 changes: 2 additions & 2 deletions test/structs/emoji_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Crux.Structs.EmojiTest do
test "create a unicode emoji" do
emoji =
%{"animated" => false, "id" => nil, "name" => "👋"}
|> Crux.Structs.Emoji.create()
|> Crux.Structs.create(Crux.Structs.Emoji)

assert emoji == %Crux.Structs.Emoji{
animated: false,
Expand Down Expand Up @@ -34,7 +34,7 @@ defmodule Crux.Structs.EmojiTest do
"animated" => false,
"id" => "340234098767560724"
}
|> Crux.Structs.Emoji.create()
|> Crux.Structs.create(Crux.Structs.Emoji)

assert emoji == %Crux.Structs.Emoji{
animated: false,
Expand Down
2 changes: 1 addition & 1 deletion test/structs/invite_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule Crux.Structs.InviteTest do
"name" => "rules"
}
}
|> Crux.Structs.Invite.create()
|> Crux.Structs.create(Crux.Structs.Invite)

assert invite == %Crux.Structs.Invite{
channel: %Crux.Structs.Channel{
Expand Down
20 changes: 17 additions & 3 deletions test/structs/message_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,27 @@ defmodule Crux.Structs.MessageTest do
"id" => "440947000364630017",
"mention_everyone" => false,
"mention_roles" => [],
"mentions" => [],
"mentions" => [
%{
"avatar" => "646a356e237350bf8b8dfde15667dfc4",
"discriminator" => "0001",
"id" => "218348062828003328",
"username" => "space",
"member" => %{
"roles" => ["222442681798885376", "273204842510548993", "376146940762783746"],
"nick" => "nickname",
"mute" => false,
"joined_at" => "2017-03-30T20:11:13.456000+00:00",
"deaf" => false
}
}
],
"pinned" => false,
"timestamp" => "2018-05-01T18:45:57.286000+00:00",
"tts" => false,
"type" => 0
}
|> Crux.Structs.Message.create()
|> Crux.Structs.create(Crux.Structs.Message)

assert message == %Crux.Structs.Message{
attachments: [],
Expand Down Expand Up @@ -63,7 +77,7 @@ defmodule Crux.Structs.MessageTest do
id: 440_947_000_364_630_017,
mention_everyone: false,
mention_roles: %MapSet{},
mentions: %MapSet{},
mentions: MapSet.new([218_348_062_828_003_328]),
pinned: false,
timestamp: "2018-05-01T18:45:57.286000+00:00",
tts: false,
Expand Down
2 changes: 1 addition & 1 deletion test/structs/overwrite_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defmodule Crux.Structs.OverwriteTest do
"allow" => 0x400,
"deny" => 0x800
}
|> Crux.Structs.Overwrite.create()
|> Crux.Structs.create(Crux.Structs.Overwrite)

assert overwrite == %Crux.Structs.Overwrite{
type: "member",
Expand Down
2 changes: 1 addition & 1 deletion test/structs/presence_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule Crux.Structs.PresenceTest do
"game" => nil,
"status" => "online"
}
|> Crux.Structs.Presence.create()
|> Crux.Structs.create(Crux.Structs.Presence)

assert presence == %Crux.Structs.Presence{
user: 218_348_062_828_003_328,
Expand Down
2 changes: 1 addition & 1 deletion test/structs/reaction_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule Crux.Structs.ReactionTest do
"me" => false,
"emoji" => %{"animated" => false, "id" => nil, "name" => "👋"}
}
|> Crux.Structs.Reaction.create()
|> Crux.Structs.create(Crux.Structs.Reaction)

assert reaction === %Crux.Structs.Reaction{
count: 5,
Expand Down
2 changes: 1 addition & 1 deletion test/structs/role_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule Crux.Structs.RoleTest do
"managed" => false,
"permissions" => 3_524_608
}
|> Crux.Structs.Role.create()
|> Crux.Structs.create(Crux.Structs.Role)

assert role == %Crux.Structs.Role{
id: 376_146_940_762_783_746,
Expand Down
2 changes: 1 addition & 1 deletion test/structs/user_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defmodule Crux.Structs.UserTest do
"id" => "218348062828003328",
"avatar" => "646a356e237350bf8b8dfde15667dfc4"
}
|> Crux.Structs.User.create()
|> Crux.Structs.create(Crux.Structs.User)

assert user == %Crux.Structs.User{
username: "space",
Expand Down
2 changes: 1 addition & 1 deletion test/structs/voice_state_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defmodule Crux.Structs.VoiceStateTest do
"self_video" => false,
"suppress" => false
}
|> Crux.Structs.VoiceState.create()
|> Crux.Structs.create(Crux.Structs.VoiceState)

assert voice_state == %Crux.Structs.VoiceState{
guild_id: 81_384_788_765_712_384,
Expand Down

0 comments on commit ced8c4e

Please sign in to comment.