【发布时间】:2014-03-26 01:54:13
【问题描述】:
我正在开发一款将 Ember 与 jquery-terminal 结合使用的应用,以帮助用户学习。对于前面的冗长问题,我深表歉意!
我喜欢以 TDD 风格工作,但我很难让它发挥作用。
我想要做的是模拟用户输入jquery-terminal 并断言正确的响应显示在终端中。我已经挖掘了源代码,也许我遗漏了一些东西,但我似乎找不到添加用户输入的地方。终端最终输出:-
<div id="terminal" class="terminal">
<div class="terminal-output"></div>
<div class="cmd" style="width: 100%;">
<span class="prompt">TryRuby:> </span>
<span></span>
<span class="cursor blink"> </span>
<span></span>
<textarea class="clipboard"></textarea>
</div>
</div>
用户输入的文本在第一个未命名的跨度中呈现,但在此处插入文本不会使其可用于jquery-terminal 在提交时我得到相同的响应,就好像它是空白一样。
我要模拟的是这个(伪代码)
test('user enters help and submits', function() {
var input = $('#terminal') // find the right node / place to bind is my problem
input.text = 'help'
keyEvent(input, 'keydown', 13) // simulate hitting enter
var match = /next: move to the next lesson/
ok(match.test($('.terminal-output'), 'Expected to find "next: move to the next lesson"')
})
现在,如果我访问该页面并手动输入,一切都会完美运行,但我希望以编程方式完成。
欢迎提出任何建议!
【问题讨论】:
-
你有这个应用程序在线吗?
-
@jcubic 不再。我最终构建了这个github.com/mfeckie/try-ruby-ember-edition,但是它没有被太多使用,并且很长时间没有收到任何爱
标签: jquery ember.js qunit jquery-terminal