小编use*_*473的帖子

在sails.js中创建配置变量?

我正在将我的应用程序从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中如何/在哪里做到这一点.

node.js express sails.js

42
推荐指数
1
解决办法
2万
查看次数

如何为Ember.js适配器/序列化器创建单元测试?

我正在构建一个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上找到构建这些测试的任何示例应用程序.

unit-testing ember.js ember-cli

8
推荐指数
2
解决办法
4202
查看次数

标签 统计

ember-cli ×1

ember.js ×1

express ×1

node.js ×1

sails.js ×1

unit-testing ×1