我正在研究一款結合了Ember和jquery-terminal
的應用程序,以幫助用戶學習。我對前面的長問題表示歉意!jQuery終端,Ember,QUnit - 自動測試問題
我喜歡以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
@jcubic沒有更多。我在最後建立https://github.com/mfeckie/try-ruby-ember-edition,但它沒有被使用太多,並沒有收到很長一段時間的愛 – muttonlamb