Code coverage report for .readme/includes/Exception/ExceptionListDocExample.js

Statements: 100% (9 / 9)      Branches: 100% (0 / 0)      Functions: 100% (0 / 0)      Lines: 100% (9 / 9)      Ignored: none     

All files » .readme/includes/Exception/ » ExceptionListDocExample.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29  1       1     1       1 1 1     1       1       1      
 
var Exception       = Divhide.Exception.Exception,
    ExceptionList   = Divhide.Exception.ExceptionList;
 
 
var errors = new ExceptionList();
 
/// is an instance of Error
expect(errors instanceof Error)
    .toEqual(true);
 
/// adding errors to ExceptionList ( you can also merge other ExceptionList! )
errors.push( new Exception("Error1") );
errors.push( new Exception("Error2") );
errors.push( new Exception("Error3") );
 
/// get length of the list
expect(errors.length)
    .toEqual(3);
 
/// get an error from the list
expect(errors.items[0].toString())
    .toEqual("Error1");
 
/// get the translated error
expect(errors.toString({ "Error1": "Error 1", "Error2": "Error 2", "Error3": "Error 3" }))
    .toEqual("Error 1, Error 2, Error 3");