Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:

env:
NODE_VERSION: 22
WRANGLER_VERSION: 3.99.0
jobs:
deploy:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -36,5 +35,4 @@ jobs:
accountId: ${{ secrets.CF_ACCOUNT_ID }}
command: "deploy --env production"
environment: "production"
wranglerVersion: ${{ env.WRANGLER_VERSION }}

1 change: 0 additions & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ jobs:
- run: npm run build
- run: npm run lint:js
- run: npm run check-types
- run: cargo clippy --all-targets --all-features
- run: npm run test
123 changes: 16 additions & 107 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ imageproc = { version = "0.25.0", default-features = false }
# logging them with `console.error`. This is great for development, but requires
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
# code size when deploying.
console_error_panic_hook = { version = "0.1.6", optional = true }
console_error_panic_hook = { version = "0.1.7", optional = true }

[dependencies.image]
# Make `image` more lightweight. We don't need every image format under the sun,
Expand All @@ -28,7 +28,6 @@ default-features = false
features = ["png"]

[dev-dependencies]
wasm-bindgen-test = "0.2"
clippy = "0.0.302"

[profile.release]
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"lint": "npm run lint:js && npm run lint:rs && npm run check-types",
"lint:js": "eslint \"**/*.{js,mjs,cjs,ts}\" \"**/*.json\"",
"lint:js:fix": "npm run lint:js -- --fix",
"lint:rs": "cargo fmt --all --check",
"lint:rs:fix": "cargo fmt --all",
"test": "vitest --run",
"lint:rs": "cargo fmt --all --check && cargo clippy --all-targets --all-features",
"lint:rs:fix": "cargo fmt --all && cargo clippy --all-targets --all-features --fix",
"test": "vitest --run && cargo test",
"test:dev": "vitest --watch"
},
"devDependencies": {
Expand Down
59 changes: 59 additions & 0 deletions src/rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use skin::*;
use std::io::Cursor;
use wasm_bindgen::prelude::*;

#[derive(Debug, PartialEq)]
enum RenderType {
Avatar,
Helm,
Expand Down Expand Up @@ -104,3 +105,61 @@ pub fn get_rendered_image(
Err(_err) => Err(js_sys::Error::new("Couldn't load skin.").into()),
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_what_to_render_type_avatar() {
assert_eq!(
what_to_render_type("avatar".to_string()),
Some(RenderType::Avatar)
);
}

#[test]
fn test_what_to_render_type_helm() {
assert_eq!(
what_to_render_type("helm".to_string()),
Some(RenderType::Helm)
);
}

#[test]
fn test_what_to_render_type_cube() {
assert_eq!(
what_to_render_type("cube".to_string()),
Some(RenderType::Cube)
);
}

#[test]
fn test_what_to_render_type_body() {
assert_eq!(
what_to_render_type("body".to_string()),
Some(RenderType::Body)
);
}

#[test]
fn test_what_to_render_type_bust() {
assert_eq!(
what_to_render_type("bust".to_string()),
Some(RenderType::Bust)
);
}

#[test]
fn test_what_to_render_type_cape() {
assert_eq!(
what_to_render_type("cape".to_string()),
Some(RenderType::Cape)
);
}

#[test]
fn test_what_to_render_type_invalid() {
assert_eq!(what_to_render_type("invalid".to_string()), None);
}
}
Loading
Loading