add default veilid config to the api

This commit is contained in:
Christien Rioux 2024-03-02 11:32:08 -05:00
parent 31bb8018f6
commit 8818e63dc0
17 changed files with 242 additions and 126 deletions

View file

@ -1624,3 +1624,8 @@ pub fn veilid_version() -> JsValue {
};
<JsValue as JsValueSerdeExt>::from_serde(&vv).unwrap()
}
#[wasm_bindgen()]
pub fn default_veilid_config() -> String {
veilid_core::default_veilid_config()
}

View file

@ -178,4 +178,9 @@ impl VeilidClient {
pub fn versionString() -> String {
veilid_core::veilid_version_string()
}
/// Return the default veilid configuration in json string format.
pub fn defaultConfig() -> String {
veilid_core::default_veilid_config()
}
}

View file

@ -28,6 +28,19 @@ describe('veilidClient', () => {
expect(version.length).toBeGreaterThan(0);
});
it('should get config string', async () => {
const defaultConfig = veilidClient.defaultConfig();
expect(typeof defaultConfig).toBe('string');
expect(defaultConfig.length).toBeGreaterThan(0);
const cfgObject1 = JSON.parse(defaultConfig);
const defaultConfigStr = JSON.stringify(cfgObject1);
const cfgObject2 = JSON.parse(defaultConfigStr);
const defaultConfigStr2 = JSON.stringify(cfgObject2);
expect(defaultConfigStr).toEqual(defaultConfigStr2);
});
it('should attach and detach', async () => {
await veilidClient.attach();
await waitForMs(2000);