我開始學習chai.js - 非常有用。我堅持瞭解如何使用chai來測試我的函數是否成功創建了一個數組。如何使用chai.js來測試我的函數是否創建一個數組?
這是一個早期的測試通過:
describe('wordSearch', function() {
it("takes an input and returns a changed input to the screen", function() {
expect(wordSearch("hello world", "world", "hello universe")).to.equal("hello universe");
});
})
,我發現一些例子在這裏:http://www.andrewsouthpaw.com/2015/01/08/beginners-guide-to-testing-with-mocha-chai/
(看他的冒泡排序功能,實現頁面的末尾)
但一些瞭解我如何測試這個功能的指針會非常有幫助。是否有必要具有捕獲一個字符串並將其轉換爲一個數組的功能?
謝謝!