代码之家  ›  专栏  ›  技术社区  ›  Sarath Damaraju

灰烬中的helper和en与传统的then有何不同

  •  0
  • Sarath Damaraju  · 技术社区  · 7 年前

    在下面的代码中,我可以使用 then 而不是 andThen 我看到一切都很好。那么,有什么特别之处呢?

    test('Clicked on the About page /about', function(assert) {
        visit('/')
        .click('a:contains("About")')
        .then(function(){
            assert.equal(currentURL(), '/about', 'SHould Navigate to about')
        })
    });
    
    test('Clicked on the About page /about', function(assert) {
        visit('/')
        .click('a:contains("About")')
        .andThen(function(){
            assert.equal(currentURL(), '/about', 'SHould Navigate to about')
        })
    });
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   acorncom    7 年前

    then 与等待完成装载的承诺有关。 andThen 在内部调用代码之前,等待余烬运行循环完成。

    另外,在Ember中的新样式测试中,测试助手(click、fillIn等)都返回承诺,我们不再需要使用 以及

    推荐文章