diff --git a/crates/matrix-sdk-crypto-nodejs/src/machine.rs b/crates/matrix-sdk-crypto-nodejs/src/machine.rs index 964b7cd1b..be6e7cd74 100644 --- a/crates/matrix-sdk-crypto-nodejs/src/machine.rs +++ b/crates/matrix-sdk-crypto-nodejs/src/machine.rs @@ -62,8 +62,10 @@ impl OlmMachine { /// asynchronous. Please use the `finalize` method. #[napi(constructor)] #[allow(clippy::new_ret_no_self)] - pub fn new() -> napi::Error { - napi::Error::from_reason("To build an `OldMachine`, please use the `initialize` method") + pub fn new() -> Result<(), napi::Error> { + Err(napi::Error::from_reason( + "To build an `OldMachine`, please use the `initialize` method", + )) } /// The unique user ID that owns this `OlmMachine` instance. diff --git a/crates/matrix-sdk-crypto-nodejs/tests/machine.test.js b/crates/matrix-sdk-crypto-nodejs/tests/machine.test.js new file mode 100644 index 000000000..b996f2b6e --- /dev/null +++ b/crates/matrix-sdk-crypto-nodejs/tests/machine.test.js @@ -0,0 +1,7 @@ +const { OlmMachine } = require('../'); + +describe(OlmMachine.name, () => { + test('cannot be instantiated', () => { + expect(() => { new OlmMachine() }).toThrow(); + }); +});