Skip to content

Commit

Permalink
test: 更新单测和快照
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanglanxiao.zlx committed Sep 17, 2023
1 parent 1f17c10 commit f0d8463
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion crates/mako/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ mod tests {
}

#[test]
#[should_panic(expected = "public_path must end with '/' or be 'runtime'")]
#[should_panic(expected = "publicPath must end with '/' and start with '/' or be 'runtime'")]
fn test_config_invalid_public_path() {
let current_dir = std::env::current_dir().unwrap();
Config::new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) {
check () {
const current_hash = requireModule.currentHash();
const publicPath = requireModule.publicPath;
return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{
return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{
return res.json();
}).then((update)=>{
return Promise.all(update.c.map((chunk)=>{
Expand Down Expand Up @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) {
}
const script = document.createElement('script');
script.timeout = 120;
script.src = url?.startsWith('/') ? url : `/${url}`;
script.src = url;
inProgress[url] = [
done
];
Expand Down Expand Up @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = url?.startsWith('/') ? url : `/${url}`;
link.href = url;
link.onerror = link.onload = function(event) {
link.onerror = link.onload = null;
if (event.type === 'load') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) {
check () {
const current_hash = requireModule.currentHash();
const publicPath = requireModule.publicPath;
return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{
return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{
return res.json();
}).then((update)=>{
return Promise.all(update.c.map((chunk)=>{
Expand Down Expand Up @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) {
}
const script = document.createElement('script');
script.timeout = 120;
script.src = url?.startsWith('/') ? url : `/${url}`;
script.src = url;
inProgress[url] = [
done
];
Expand Down Expand Up @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = url?.startsWith('/') ? url : `/${url}`;
link.href = url;
link.onerror = link.onload = function(event) {
link.onerror = link.onload = null;
if (event.type === 'load') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function createRuntime(makoModules, entryModuleId) {
check () {
const current_hash = requireModule.currentHash();
const publicPath = requireModule.publicPath;
return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{
return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{
return res.json();
}).then((update)=>{
return Promise.all(update.c.map((chunk)=>{
Expand Down Expand Up @@ -256,7 +256,7 @@ function createRuntime(makoModules, entryModuleId) {
}
const script = document.createElement('script');
script.timeout = 120;
script.src = url?.startsWith('/') ? url : `/${url}`;
script.src = url;
inProgress[url] = [
done
];
Expand Down Expand Up @@ -295,7 +295,7 @@ function createRuntime(makoModules, entryModuleId) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = url?.startsWith('/') ? url : `/${url}`;
link.href = url;
link.onerror = link.onload = function(event) {
link.onerror = link.onload = null;
if (event.type === 'load') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) {
check () {
const current_hash = requireModule.currentHash();
const publicPath = requireModule.publicPath;
return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{
return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{
return res.json();
}).then((update)=>{
return Promise.all(update.c.map((chunk)=>{
Expand Down Expand Up @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) {
}
const script = document.createElement('script');
script.timeout = 120;
script.src = url?.startsWith('/') ? url : `/${url}`;
script.src = url;
inProgress[url] = [
done
];
Expand Down Expand Up @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = url?.startsWith('/') ? url : `/${url}`;
link.href = url;
link.onerror = link.onload = function(event) {
link.onerror = link.onload = null;
if (event.type === 'load') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) {
check () {
const current_hash = requireModule.currentHash();
const publicPath = requireModule.publicPath;
return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{
return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{
return res.json();
}).then((update)=>{
return Promise.all(update.c.map((chunk)=>{
Expand Down Expand Up @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) {
}
const script = document.createElement('script');
script.timeout = 120;
script.src = url?.startsWith('/') ? url : `/${url}`;
script.src = url;
inProgress[url] = [
done
];
Expand Down Expand Up @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = url?.startsWith('/') ? url : `/${url}`;
link.href = url;
link.onerror = link.onload = function(event) {
link.onerror = link.onload = null;
if (event.type === 'load') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) {
check () {
const current_hash = requireModule.currentHash();
const publicPath = requireModule.publicPath;
return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{
return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{
return res.json();
}).then((update)=>{
return Promise.all(update.c.map((chunk)=>{
Expand Down Expand Up @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) {
}
const script = document.createElement('script');
script.timeout = 120;
script.src = url?.startsWith('/') ? url : `/${url}`;
script.src = url;
inProgress[url] = [
done
];
Expand Down Expand Up @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = url?.startsWith('/') ? url : `/${url}`;
link.href = url;
link.onerror = link.onload = function(event) {
link.onerror = link.onload = null;
if (event.type === 'load') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) {
check () {
const current_hash = requireModule.currentHash();
const publicPath = requireModule.publicPath;
return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{
return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{
return res.json();
}).then((update)=>{
return Promise.all(update.c.map((chunk)=>{
Expand Down Expand Up @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) {
}
const script = document.createElement('script');
script.timeout = 120;
script.src = url?.startsWith('/') ? url : `/${url}`;
script.src = url;
inProgress[url] = [
done
];
Expand Down Expand Up @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = url?.startsWith('/') ? url : `/${url}`;
link.href = url;
link.onerror = link.onload = function(event) {
link.onerror = link.onload = null;
if (event.type === 'load') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) {
check () {
const current_hash = requireModule.currentHash();
const publicPath = requireModule.publicPath;
return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{
return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{
return res.json();
}).then((update)=>{
return Promise.all(update.c.map((chunk)=>{
Expand Down Expand Up @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) {
}
const script = document.createElement('script');
script.timeout = 120;
script.src = url?.startsWith('/') ? url : `/${url}`;
script.src = url;
inProgress[url] = [
done
];
Expand Down Expand Up @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = url?.startsWith('/') ? url : `/${url}`;
link.href = url;
link.onerror = link.onload = function(event) {
link.onerror = link.onload = null;
if (event.type === 'load') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) {
check () {
const current_hash = requireModule.currentHash();
const publicPath = requireModule.publicPath;
return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{
return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{
return res.json();
}).then((update)=>{
return Promise.all(update.c.map((chunk)=>{
Expand Down Expand Up @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) {
}
const script = document.createElement('script');
script.timeout = 120;
script.src = url?.startsWith('/') ? url : `/${url}`;
script.src = url;
inProgress[url] = [
done
];
Expand Down Expand Up @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = url?.startsWith('/') ? url : `/${url}`;
link.href = url;
link.onerror = link.onload = function(event) {
link.onerror = link.onload = null;
if (event.type === 'load') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) {
check () {
const current_hash = requireModule.currentHash();
const publicPath = requireModule.publicPath;
return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{
return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{
return res.json();
}).then((update)=>{
return Promise.all(update.c.map((chunk)=>{
Expand Down Expand Up @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) {
}
const script = document.createElement('script');
script.timeout = 120;
script.src = url?.startsWith('/') ? url : `/${url}`;
script.src = url;
inProgress[url] = [
done
];
Expand Down Expand Up @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = url?.startsWith('/') ? url : `/${url}`;
link.href = url;
link.onerror = link.onload = function(event) {
link.onerror = link.onload = null;
if (event.type === 'load') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) {
check () {
const current_hash = requireModule.currentHash();
const publicPath = requireModule.publicPath;
return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{
return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{
return res.json();
}).then((update)=>{
return Promise.all(update.c.map((chunk)=>{
Expand Down Expand Up @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) {
}
const script = document.createElement('script');
script.timeout = 120;
script.src = url?.startsWith('/') ? url : `/${url}`;
script.src = url;
inProgress[url] = [
done
];
Expand Down Expand Up @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = url?.startsWith('/') ? url : `/${url}`;
link.href = url;
link.onerror = link.onload = function(event) {
link.onerror = link.onload = null;
if (event.type === 'load') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) {
check () {
const current_hash = requireModule.currentHash();
const publicPath = requireModule.publicPath;
return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{
return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{
return res.json();
}).then((update)=>{
return Promise.all(update.c.map((chunk)=>{
Expand Down Expand Up @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) {
}
const script = document.createElement('script');
script.timeout = 120;
script.src = url?.startsWith('/') ? url : `/${url}`;
script.src = url;
inProgress[url] = [
done
];
Expand Down Expand Up @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = url?.startsWith('/') ? url : `/${url}`;
link.href = url;
link.onerror = link.onload = function(event) {
link.onerror = link.onload = null;
if (event.type === 'load') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function createRuntime(makoModules, entryModuleId) {
check () {
const current_hash = requireModule.currentHash();
const publicPath = requireModule.publicPath;
return fetch(`${publicPath?.startsWith('/') ? '' : '/'}${publicPath}${current_hash}.hot-update.json`).then((res)=>{
return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{
return res.json();
}).then((update)=>{
return Promise.all(update.c.map((chunk)=>{
Expand Down Expand Up @@ -255,7 +255,7 @@ function createRuntime(makoModules, entryModuleId) {
}
const script = document.createElement('script');
script.timeout = 120;
script.src = url?.startsWith('/') ? url : `/${url}`;
script.src = url;
inProgress[url] = [
done
];
Expand Down Expand Up @@ -293,7 +293,7 @@ function createRuntime(makoModules, entryModuleId) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = url?.startsWith('/') ? url : `/${url}`;
link.href = url;
link.onerror = link.onload = function(event) {
link.onerror = link.onload = null;
if (event.type === 'load') {
Expand Down
Loading

0 comments on commit f0d8463

Please sign in to comment.