From 5216cd0089cd25cd4e87423d5669a799f5d82663 Mon Sep 17 00:00:00 2001 From: Charles Lanahan Date: Mon, 8 Jan 2024 10:16:29 -0500 Subject: [PATCH] SaiderWrapper removed *_with_* methods --- wasm/src/primitives/saider.rs | 55 +++++++---------------------------- wasm/tests/test_wasm.rs | 15 ++++++++++ 2 files changed, 26 insertions(+), 44 deletions(-) diff --git a/wasm/src/primitives/saider.rs b/wasm/src/primitives/saider.rs index be57d62..0f77c0f 100644 --- a/wasm/src/primitives/saider.rs +++ b/wasm/src/primitives/saider.rs @@ -1,10 +1,19 @@ use std::ops::Deref; -use crate::{error::*, ValueWrapper, Wrap}; -use cesride_core::{data::Value, Matter, Saider}; use js_sys::Array; use wasm_bindgen::prelude::*; +use crate::{ + error::*, + ValueWrapper, + Wrap +}; +use cesride_core::{ + data::Value, + Matter, + Saider +}; + #[wasm_bindgen(js_name = Saider)] #[derive(Clone)] pub struct SaiderWrapper(pub(crate) Saider); @@ -111,48 +120,6 @@ impl SaiderWrapper { Ok(ret) } - pub fn new_with_sad( - sad: ValueWrapper, - label: Option, - kind: Option, - ignore: Option, - code: Option, - ) -> Result { - let ignore = ignore - .map(|a| a.iter().map(|v| v.as_string().unwrap_or_default()).collect::>()); - let ignore = ignore.as_deref().map(|a| a.iter().map(String::as_str).collect::>()); - let ignore = ignore.as_deref(); - let saider = Saider::new_with_sad( - &Value::from(sad), - label.as_deref(), - kind.as_deref(), - ignore, - code.as_deref(), - ) - .as_js()?; - Ok(SaiderWrapper(saider)) - } - - pub fn new_with_raw(raw: &[u8], code: Option) -> Result { - let saider = Saider::new_with_raw(raw, code.as_deref()).as_js()?; - Ok(SaiderWrapper(saider)) - } - - pub fn new_with_qb64b(qb64b: &[u8]) -> Result { - let saider = Saider::new_with_qb64b(qb64b).as_js()?; - Ok(SaiderWrapper(saider)) - } - - pub fn new_with_qb64(qb64: &str) -> Result { - let saider = Saider::new_with_qb64(qb64).as_js()?; - Ok(SaiderWrapper(saider)) - } - - pub fn new_with_qb2(qb2: &[u8]) -> Result { - let saider = Saider::new_with_qb2(qb2).as_js()?; - Ok(SaiderWrapper(saider)) - } - pub fn code(&self) -> String { self.0.code() } diff --git a/wasm/tests/test_wasm.rs b/wasm/tests/test_wasm.rs index b3d656c..26ee91f 100644 --- a/wasm/tests/test_wasm.rs +++ b/wasm/tests/test_wasm.rs @@ -7,7 +7,9 @@ use cesride_wasm::BexterWrapper; use cesride_wasm::CesrideMatterCodex; use cesride_wasm::CigarWrapper; use cesride_wasm::DaterWrapper; +use cesride_wasm::SaiderWrapper; use cesride_wasm::VerferWrapper; +use cesride_wasm::ValueWrapper; /* These dater tests are transcriptions from the first two test_dater tests in @@ -88,3 +90,16 @@ fn test_verfer_convenience() { assert_eq!(verf_wrapper.qb64b(), verf_wrapper_2.qb64b()); assert_eq!(verf_wrapper.qb2(), verf_wrapper_2.qb2()); } + +#[wasm_bindgen_test] +fn test_serder_convenience() { + // TODO implement +} + +#[wasm_bindgen_test] +fn test_saider_convenience() { + let sad = r#"{"d":""}"#; + let wrapper = SaiderWrapper::new(Some(ValueWrapper::new(&sad)), + None, None, None, None, None, None, None, None).unwrap(); + assert_eq!(wrapper.code(), wrapper.code()); +}