问题标签 [ic-ajax]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
javascript - ember 控制器中返回承诺的单元测试操作
我有一个执行异步操作的控制器,我想对其进行测试:
...在测试中:
但是,这不可避免地会导致在另一个不相关的测试用例中抛出错误:
这一定会发生,因为this.set('fooLastDoneAt', moment());
在这个测试用例完成之后执行,并且测试运行器已经teardown
为这个模块做了一个,然后继续下一个;当动作仍在执行时。
有没有办法让我等待一个动作异步完成,然后再进行下一步的单元测试?
@kingpin2k 建议使用此解决方案,您可以在其中将承诺延迟对象传递到操作中。但是,在我的应用程序中,应用程序本身永远不会这样做,如果我需要修改我的应用程序源以便对其进行测试,这似乎是一个基本问题 - 特别是因为它增加了复杂性。
还有其他方法可以使测试执行等待操作完成吗?
ember-cli - Why is ic-ajax not defined within certain functions in Ember CLI?
Forgive my ignorance, but I can't get ic-ajax working inside of certain functions.
Specifically, I'd like to get a test like this working, but for Ember CLI: e.g. http://coderberry.herokuapp.com/testing-your-ember-application#30
I can call ajax inside Ember.Object.Extend and outside of functions and object definitions, but not in modules, tests, or Ember.Route's model function.
Am I misunderstanding something or is there a misconfiguration in my app?
I've figured out that within functions I can do:
but I'm pretty sure import
at the top of the file is supposed to work.
I'm experiencing this on Ember 0.40.0 (both in my existing app and a fresh app). See below for more specifics where I'm finding it undefined. Setting var ajax = icAjaxRaw
outside of the functions does not work either. I'm at a bit of a loose end so any help you could give in this regard would be great.
users-test.js:
---> icAjaxDefineFixture IS defined here
icAjaxDefineFixture --> UNDEFINED
icAjaxDefineFixture --> UNDEFINED
Brocfile.js (I don't think these are actually needed with the new ember-cli-ic-ajax addon):
ember.js - 使用 ic-ajax 的 declareFixture 声明的 ember 数据访问夹具如何?
我正在尝试使用ember-cli
andember-cli-ic-ajax
用于 Ember Data 固定装置。我已导入ic.ajax.defineFixture
为icDefineFixture
.
这不会引发任何错误,所以我知道我正在成功导入该函数。然后我创建一个记录,这没问题:
但是当我尝试将其保存在控制器操作中时:
我收到 404 错误,因为 ember 数据正在联系我在测试时没有后端的服务器。
我很困惑 Ember Data 应该如何知道使用 ic-ajax 的 ajax 方法。这是我必须手动设置的吗?我还没有找到任何关于它的文档。
谢谢!
javascript - Should I and how to transitionToRoute in a promise callback
In an Ember controller, I want to call my API to create a user and on success, transitionToRoute. This is what I currently want to work:
But when I place a debugger
in the method, this
is no longer the controller object and is out of scope to call transitionToRoute
.
I've only ever written hacky javascript, but I'm trying to learn core concepts and some frameworks. Is this the right way to use a promise? And is this the right place in Ember to put a transition?
ember.js - ic-ajax中的ic代表什么
ic-ajax 中的 ic 是首字母缩写词还是某事物的音标?
在谷歌或图书馆 README.md 上找不到任何东西。
javascript - 使用 Ember 插件 ember-plupload 上传照片
我已经使用 ember-plupload 来上传图片。现在我为此编写了一个组件。我可以从我的机器上打开并选择图片。但是我不知道下一步该做什么。我必须将发布请求发送到我的服务器端点带有正文参数 { photo_file: image file }。我的代码如下。
组件.hbs
组件.js
我能够获取文件名并编码 base64 值。但不确定如何将请求发送到服务器端点。
我能够从邮递员应用程序发出正确的请求。在请求的正文中,我选择了文件选项,它直接让我可以选择从那里选择一个文件。请求成功,照片被添加到当我选择图像并发送请求时的端点
我应该如何在我的应用程序中执行此操作?