feat(crypto-nodejs): Make Versions a class, not a JS object.

This commit is contained in:
Ivan Enderlin
2023-03-16 10:33:41 +01:00
parent e1f6fd8a1e
commit c2d3afffff
2 changed files with 7 additions and 6 deletions

View File

@@ -34,23 +34,23 @@ pub mod types;
pub mod vodozemac;
/// Object containing the versions of the Rust libraries we are using.
#[napi(object)]
#[napi]
pub struct Versions {
/// The version of the vodozemac crate.
#[napi(getter)]
pub vodozemac: &'static str,
pub vodozemac: String,
/// The version of the matrix-sdk-crypto crate.
#[napi(getter)]
pub matrix_sdk_crypto: &'static str,
pub matrix_sdk_crypto: String,
}
/// Get the versions of the Rust libraries we are using.
#[napi(js_name = "getVersions")]
pub fn get_versions() -> Versions {
Versions {
vodozemac: matrix_sdk_crypto::vodozemac::VERSION,
matrix_sdk_crypto: matrix_sdk_crypto::VERSION,
vodozemac: matrix_sdk_crypto::vodozemac::VERSION.to_owned(),
matrix_sdk_crypto: matrix_sdk_crypto::VERSION.to_owned(),
}
}

View File

@@ -36,8 +36,9 @@ describe("Versions", () => {
expect(versions).toBeInstanceOf(Versions);
expect(versions.vodozemac).toBeDefined();
expect(versions.matrix_sdk_crypto).toBeDefined();
expect(versions.matrixSdkCrypto).toBeDefined();
});
});
describe(OlmMachine.name, () => {