All files / lib document.js

100% Statements 21/21
76.47% Branches 13/17
100% Functions 3/3
100% Lines 21/21
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 46 47    8x 8x 8x 8x           35x 1x     34x 1x     33x 33x 33x 33x 33x 33x           15x 1x     14x 14x 14x 14x       7x          
class Document {
  constructor (url = '', title = '', description = '', content = {}) {
    this.url = url
    this.title = title
    this.description = description
    this.content = content
  }
}
 
class Link {
  constructor (url, method, encoding = 'application/json', fields = [], title = '', description = '') {
    if (url === undefined) {
      throw new Error('url argument is required')
    }
 
    if (method === undefined) {
      throw new Error('method argument is required')
    }
 
    this.url = url
    this.method = method
    this.encoding = encoding
    this.fields = fields
    this.title = title
    this.description = description
  }
}
 
class Field {
  constructor (name, required = false, location = '', description = '') {
    if (name === undefined) {
      throw new Error('name argument is required')
    }
 
    this.name = name
    this.required = required
    this.location = location
    this.description = description
  }
}
 
module.exports = {
  Document: Document,
  Link: Link,
  Field: Field
}