test(tauri.js) update fixture app and fix build/dev e2e tests (#1058)

This commit is contained in:
Lucas Fernandes Nogueira 2020-10-17 20:53:24 -03:00 committed by GitHub
parent 92908c7e91
commit a3b724738e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 14 deletions

View File

@ -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'
}
}

View File

@ -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'
}

View File

@ -66,7 +66,8 @@ function runDevTest(tauriConfig) {
describe('Tauri Dev', () => {
const build = {
distDir: distDir
distDir: distDir,
withGlobalTauri: true
}
const devServer = startDevServer()

View File

@ -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)

View File

@ -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" ]

View File

@ -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| {
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();
webview.terminate();
}
}
Ok(())