Skip to content

Commit

Permalink
test: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
twlite committed Nov 4, 2024
1 parent f01152c commit 6d2e9ff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions __test__/svg-canvas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ test.beforeEach((t) => {
t.context.canvas = createCanvas(1024, 768, SvgExportFlag.ConvertTextToPaths)
})

test('should be able to adjust size', (t) => {
const { canvas } = t.context
canvas.width = 512
canvas.height = 384

t.is(canvas.width, 512)
t.is(canvas.height, 384)
})

test('should be able to export path/arc/rect', (t) => {
const { canvas } = t.context
const ctx = canvas.getContext('2d')
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ impl<'scope> SVGCanvas<'scope> {
}
}

#[napi(setter)]
#[napi(setter)]
pub fn set_width(&mut self, env: Env, width: i32) -> Result<()> {
let width = (if width <= 0 { 350 } else { width }) as u32;
self.width = width;
Expand Down
2 changes: 1 addition & 1 deletion src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ impl Path {
#[napi(js_name = "toSVGString")]
pub fn to_svg_string(&self, env: Env) -> Result<JsString> {
let sk_string = self.inner.to_svg_string();
unsafe { env.create_string_from_c_char(sk_string.ptr, sk_string.length) }
unsafe { env.create_string_from_c_char(sk_string.ptr, sk_string.length as isize) }
}

#[napi]
Expand Down

0 comments on commit 6d2e9ff

Please sign in to comment.