4

Warning: I am a newbie. Thanks in advance for any help.

Pavlov/QUnit is causing problems with the router in my ember app. When using QUnit alone, the following test passes:

test "/contacts", ->
  expect(1)
  visit('/contacts').then ->
    ok(exists(".nav"), "The navbar was rendered")

But when using Pavlov with QUnit, the following test dies:

describe 'contacts index', ->
    it 'does render index', ->
      visit('/contacts').then ->
        assert(exists(".nav")).isTrue('The navbar was rendered')

and produces a "has no method 'getHandler'" error in the collectObjects method when the following is executed:

var handler = router.getHandler(result.handler);

Stack trace is below:

TypeError: Object #<Object> has no method 'getHandler'
    at collectObjects (http://localhost:3000/assets/test_helper.js:37674:28)
    at Object.Router.handleURL (http://localhost:3000/assets/test_helper.js:37347:9)
    at Ember.Router.Ember.Object.extend.handleURL (http://localhost:3000/assets/test_helper.js:38135:17)
    at Ember.Application.Ember.Namespace.extend.handleURL (http://localhost:3000/assets/test_helper.js:41451:12)
    at http://localhost:3000/assets/test_helper.js:18367:19
    at Object.Ember.handleErrors (http://localhost:3000/assets/test_helper.js:14228:17)
    at invoke (http://localhost:3000/assets/test_helper.js:18365:16)
    at Object.tryable (http://localhost:3000/assets/test_helper.js:18550:14)
    at Object.Ember.tryFinally (http://localhost:3000/assets/test_helper.js:15023:24)
    at Object.Ember.run (http://localhost:3000/assets/test_helper.js:18554:16)

How to make JQuery + CSS Vertical Tabs

Having trouble with my tabs, the Jquery is not functioning as i expect it to.

Im trying to create verticle tabs to display different information, but my jquery is not functioning.

  1. I am trying to hide all the divs except the first one.
  2. Then when one of the tab lists is clicked the active class gets added to that and removed from the other.
  3. finally hide all the divs and show the one which was clicked.

Click for jsfiddle demo

   $(document).ready(function() {
    tabContent();
})

function tabContent() {
    $('#tabsD div:not(:first)').hide(); 
    $('#tab-container li').click(function(event){
        var id = $(event.target).index();
        $('.active').removeClass('active');
        $(event.target).addClass('active');
        $('#tabsD div').hide().eq(id).show();
    });
}
4

2 回答 2

3

像这样设置 Ember-testing/QUnit 测试:

App.setupForTesting();
App.injectTestHelpers();

module("Integration Tests", {
  setup: function() {
    App.reset();
    Ember.run(App, App.advanceReadiness);
  }
});

当然,替换App为您的应用程序的名称。

新的测试指南目前建议这样做,但没有显示代码。

于 2013-07-15T22:05:58.930 回答
0

我对 QUnit 也有同样的问题。测试在我的 Ember 应用程序准备好之前就开始了,所以调用visit()会失败。

尝试将 QUnit 自动启动标志设置为 false ( http://api.qunitjs.com/QUnit.config/ ) 并QUnit.start()从应用程序就绪回调中调用。这为我修复了它,如果您需要更多帮助,您可以查看这个 repo:https ://github.com/remichaignon/ember-boilerplate

于 2013-06-16T22:32:38.557 回答