我正在尝试在表单上实施一些单元测试,以查看验证规则是否按预期工作。
从这个页面上:https : //github.com/aurelia/testing/issues/63
我发现了这个实现:https : //github.com/aurelia/validation/blob/master/test/validate-binding-behavior.ts
我试图在我的项目中实现它
login.spec.js
import {bootstrap} from 'aurelia-bootstrapper';
import {StageComponent} from 'aurelia-testing';
import {PLATFORM} from 'aurelia-pal';
import { configure, blur, change } from './shared';
import { Login } from './login';
describe('ValidateBindingBehavior', () => {
it('sets validateTrigger', (done) => {
const component = StageComponent
.withResources(PLATFORM.moduleName('features/account/login/login'))
.inView('<login></login>')
.boundTo({});
component.bootstrap(configure);
let viewModel;
const renderer = { render: jasmine.createSpy() };
component.create(bootstrap)
// grab some references.
.then(() => {
viewModel = component.viewModel;
viewModel.controller.addRenderer(renderer);
})
.then(() => expect(viewModel.controller.errors.length).toBe(0))
.then(() …Run Code Online (Sandbox Code Playgroud) 我正在使用带有 webpack 和 handlebars-loader(用于 webpack 的把手模板加载器)的handlebars 来实现一个多页 web 应用程序。下面是我的视图文件夹的结构(.hbs 文件)
成分
布局
索引.hbs
product-1.hbs
product-2.hbs
...
我的问题是我在车把中看到了“部分阻止”的奇怪行为。我有两个布局来包装每个页面的主要内容。但我的布局没有在右行加载“部分块”。我在布局中使用部分块的任何地方,把手都会在该位置关闭正文和 html 标记,并在 html 关闭标记之后呈现部分块内容。
下面是我在 body 内加载部分块的示例默认布局:
<!DOCTYPE html>
<html dir="rtl">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>{{meta.title}}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body class="theme-light">
{{#if @partial-block}}
{{> @partial-block }}
{{/if}}
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我的 index.hbs 文件使用默认布局
{{> layouts/default }}
<main id="index" class="index">
<p>This is index content</p>
</main>
{{layouts/default}}
Run Code Online (Sandbox Code Playgroud)
并呈现 html 文件
<!DOCTYPE html>
<html dir="rtl">
<head>
<meta charset="utf-8">
<meta …Run Code Online (Sandbox Code Playgroud)