Code coverage report for .readme/includes/Schema/SchemaSerializationExample.js

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

All files » .readme/includes/Schema/ » SchemaSerializationExample.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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45  1       1             1 1       1   1           1   1           1 1     1 1     1 1    
 
var Schema = Divhide.Schema;
 
 
/// String schema
var schema = Schema.string()
                .required()
                .min(3)
                .max(5);
 
 
/// returns the value
var value = schema.value("hello");
expect(value).toBe("hello");
 
 
/// value is required!
expect(
    function(){
        schema.value();
    })
    .toThrowError("Value is required., The minimum value allowed is 3.");
 
 
/// value is required!
expect(
    function(){
        schema.value("hello world");
    })
    .toThrow(new Error("The maximum value allowed is 5."));
 
 
/// Check if is valid
var isValid = schema.isValid("");
expect(isValid).toBe(false);
 
 
var isValid = schema.isValid("hello");
expect(isValid).toBe(true);
 
 
var isValid = schema.isValid("hello world");
expect(isValid).toBe(false);