我正在将我的应用程序从Express转换为sails.js - 有没有办法在Sails中做这样的事情?
从我app.js在Express中的文件:
var globals = {
name: 'projectName',
author: 'authorName'
};
app.get('/', function (req, res) {
globals.page_title = 'Home';
res.render('index', globals);
});
Run Code Online (Sandbox Code Playgroud)
这让我可以在每个视图上访问这些变量,而无需将它们硬编码到模板中.不知道在Sails中如何/在哪里做到这一点.
我正在构建一个Ember CLI应用程序(v0.2.3),我为我的应用程序中的适配器和序列化器生成了一些单元测试.生成的代码如下所示:
// app/serializers/my-model-test.js
// Replace this with your real tests.
test('it serializes records', function (assert) {
var record = this.subject();
var serializedRecord = record.serialize();
assert.ok(serializedRecord);
});
Run Code Online (Sandbox Code Playgroud)
和
// app/adapter/application-test.js
// Replace this with your real tests.
test('it exists', function (assert) {
var adapter = this.subject();
assert.ok(adapter);
});
Run Code Online (Sandbox Code Playgroud)
我在这些测试中放了什么?我为我的模型和组件构建了验收测试和单元测试,但不确定在这些单元测试中需要进行哪些测试.无法找到有关构建这些单元测试的文档,也无法在GH上找到构建这些测试的任何示例应用程序.