मैं निर्धारित करने के लिए क्यों एक sails.js अनुप्रयोग में मेरी इकाई परीक्षण अपेक्षित ढंग से काम नहीं कर रहा है कुछ मदद करना चाहते हैं।Bluebird वादा मोचा में प्रत्येक/चाय परीक्षण काम नहीं कर रहा
मैं mails, chai और bluebird वादा लाइब्रेरी का उपयोग sails.js ऐप पर कर रहा हूं।
- TagsService.create (नाम) विधि है, जो एक नाम पैरामीटर स्वीकार करता है के लिए एक परीक्षण बनाएँ:
क्या मैं हासिल करना चाहते हैं।
- टेस्ट है कि इस विधि अमान्य नाम मैं
- पारित नाम पैरामीटर की आवश्यकता है और कम से कम 121 वर्ण लंबा
मैं वर्तमान में क्या है होना चाहिए के आधार पर एक नया टैग रिकॉर्ड बनाने नहीं होगा:
// Test the 'create' method
describe('Method \'create\' test result: \n', function() {
// Test that name is required and less than 121 chars long
it('Must receive the name parameter and be less than 121 chars long', function(done) {
\t \t
// It should not accept any of the following names
var names = ['',' ','thisstringislongerthanthemaxof121characterslongthisstringislongerthanthemaxof121characterslongthisstringislongerthanthema',[],[{}],[{test: 'test'}],'wrongchars*[]$£%fsf','$%@~}[','£$%jkdfi',' $%"£asdwdFDE','hD8U £$&{DS ds'];
sails.bluebird.each(names,function(name){
TagsService.create(name).then(function(data){
assert.propertyVal(data,'status','err','An error was NOT returned - even though names provided should be invalid');
});
}).then(function(){
done();
});
\t \t
});
});
क्या होता है इसे पारित करने के लिए, भले ही मैं कोई मान्य नाम में पास या विधि से अशक्त लौटने लगता है।
भी देखें https://github.com/domenic/chai-as-promised:
यहाँ मेरी परिणाम है –