diff --git a/cli/tauri.js/jest.config.js b/cli/tauri.js/jest.config.js index 91143cebf..a7e7c0704 100644 --- a/cli/tauri.js/jest.config.js +++ b/cli/tauri.js/jest.config.js @@ -41,6 +41,7 @@ module.exports = { transform: { 'templates[\\\\/](tauri|mutation-observer).js': './test/jest/raw-loader-transformer.js', + 'api[\\\\/]tauri.bundle.umd.js': './test/jest/raw-loader-transformer.js', '\\.(js|ts)$': 'babel-jest' } } diff --git a/cli/tauri.js/test/jest/__tests__/build.spec.js b/cli/tauri.js/test/jest/__tests__/build.spec.js index f0a32cf50..836c83927 100644 --- a/cli/tauri.js/test/jest/__tests__/build.spec.js +++ b/cli/tauri.js/test/jest/__tests__/build.spec.js @@ -61,7 +61,8 @@ function runBuildTest(tauriConfig) { describe('Tauri Build', () => { const build = { devPath: distDir, - distDir: distDir + distDir: distDir, + withGlobalTauri: true } it.each` @@ -77,6 +78,9 @@ describe('Tauri Build', () => { debug: flag === 'debug' }, tauri: { + allowlist: { + all: true + }, embeddedServer: { active: mode === 'embedded-server' } diff --git a/cli/tauri.js/test/jest/__tests__/dev.spec.js b/cli/tauri.js/test/jest/__tests__/dev.spec.js index 64a7c4075..1772cce1b 100644 --- a/cli/tauri.js/test/jest/__tests__/dev.spec.js +++ b/cli/tauri.js/test/jest/__tests__/dev.spec.js @@ -66,7 +66,8 @@ function runDevTest(tauriConfig) { describe('Tauri Dev', () => { const build = { - distDir: distDir + distDir: distDir, + withGlobalTauri: true } const devServer = startDevServer() diff --git a/cli/tauri.js/test/jest/fixtures/app/dist/index.html b/cli/tauri.js/test/jest/fixtures/app/dist/index.html index 7e4f0df64..7f0aed006 100644 --- a/cli/tauri.js/test/jest/fixtures/app/dist/index.html +++ b/cli/tauri.js/test/jest/fixtures/app/dist/index.html @@ -36,7 +36,7 @@ return window.__TAURI__.fs .writeFile( { - file: 'tauri-test.txt', + path: 'tauri-test.txt', contents: contents }, options @@ -136,7 +136,7 @@ }) setTimeout(function () { - window.__TAURI__.invoke({ + window.__TAURI_INVOKE_HANDLER__({ cmd: 'exit' }) }, 15000) diff --git a/cli/tauri.js/test/jest/fixtures/app/src-tauri/Cargo.toml b/cli/tauri.js/test/jest/fixtures/app/src-tauri/Cargo.toml index ff5893dfd..e2c06c290 100644 --- a/cli/tauri.js/test/jest/fixtures/app/src-tauri/Cargo.toml +++ b/cli/tauri.js/test/jest/fixtures/app/src-tauri/Cargo.toml @@ -27,7 +27,7 @@ serde_derive = "1.0" tiny_http = "0.7" phf = "0.8.0" includedir = "0.6.0" -tauri = { path = "../../../../../../../tauri", features = [ "all-api", "edge" ] } +tauri = { path = "../../../../../../../tauri", features = [ "all-api" ] } [features] embedded-server = [ "tauri/embedded-server" ] diff --git a/cli/tauri.js/test/jest/fixtures/app/src-tauri/src/main.rs b/cli/tauri.js/test/jest/fixtures/app/src-tauri/src/main.rs index d74bd4b54..89f6af74f 100644 --- a/cli/tauri.js/test/jest/fixtures/app/src-tauri/src/main.rs +++ b/cli/tauri.js/test/jest/fixtures/app/src-tauri/src/main.rs @@ -7,23 +7,26 @@ extern crate serde_json; fn main() { tauri::AppBuilder::new() .setup(|webview, _| { - let handle = webview.handle(); + let mut webview_ = webview.as_mut(); tauri::event::listen(String::from("hello"), move |_| { - tauri::event::emit(&handle, String::from("reply"), Some("{ msg: 'TEST' }".to_string())); + tauri::event::emit( + &mut webview_, + String::from("reply"), + Some("{ msg: 'TEST' }".to_string()), + ) + .unwrap(); }); - webview.eval("window.onTauriInit && window.onTauriInit()").unwrap(); + webview.eval("window.onTauriInit && window.onTauriInit()"); }) - .invoke_handler(|webview, arg| { + .invoke_handler(|webview, arg| { use cmd::Cmd::*; match serde_json::from_str(arg) { - Err(e) => { - Err(e.to_string()) - } + Err(e) => Err(e.to_string()), Ok(command) => { match command { // definitions for your custom commands from Cmd here - Exit { } => { - webview.exit(); + Exit {} => { + webview.terminate(); } } Ok(())