Skip to content

Commit

Permalink
Add tests for file skins
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverSchlueter committed Nov 21, 2024
1 parent bb1ed47 commit c563fc0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package de.oliver.fancynpcs.tests.impl.api.skin;

import de.oliver.fancynpcs.FancyNpcs;
import de.oliver.fancynpcs.api.skins.SkinData;
import de.oliver.fancynpcs.skins.SkinFetcherImpl;
import de.oliver.fancynpcs.tests.annotations.FNBeforeEach;
import de.oliver.fancynpcs.tests.annotations.FNTest;
import org.bukkit.entity.Player;

import java.io.File;

public class SkinFetcherTest {

private SkinFetcherImpl skinFetcher;
Expand Down Expand Up @@ -51,4 +54,30 @@ public void testSkinByURL(Player player) {
assert skin.textureSignature() != null && !skin.textureSignature().isEmpty();
}

@FNTest(name = "Test fetch skin by file")
public void testSkinByFile(Player player) {
SkinData skin = skinFetcher.getByFile("plugins/FancyNpcs/testskin.png");
FancyNpcs.getInstance().getPlugin().saveResource("testskin.png", false);

assert skin != null;
assert skin.identifier().equals("src/test/resources/skin.png");
assert skin.type().equals(SkinData.SkinType.FILE);
assert skin.variant().equals(SkinData.SkinVariant.DEFAULT);
assert skin.textureValue() != null && !skin.textureValue().isEmpty();
assert skin.textureSignature() != null && !skin.textureSignature().isEmpty();

new File("plugins/FancyNpcs/testskin.png").delete();
}

@FNTest(name = "Test get skin")
public void testGetSkin(Player player) {
SkinData skin = skinFetcher.get("skinname", "value", "signature");

assert skin != null;
assert skin.identifier().equals("skinname");
assert skin.type().equals(SkinData.SkinType.VALUE_SIGNATURE);
assert skin.variant().equals(SkinData.SkinVariant.DEFAULT);
assert skin.textureValue().equals("value");
assert skin.textureSignature().equals("signature");
}
}
Binary file added src/main/resources/testskin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c563fc0

Please sign in to comment.