All files index.js

75% Statements 6/8
100% Branches 0/0
33.33% Functions 1/3
75% Lines 6/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 472x     2x           9x         8x                                 8x                           2x  
const Trembita = require('trembita');
 
/** Class representing a LanguageToolClient. */
const LanguageToolClient = class LanguageToolClient extends Trembita {
  /**
   * Create a client.
   * @param {string} endpoint - LanguageTool api v2 url
   */
  constructor() {
    super(...arguments);
    /**
     * Get a list of supported languages.
     * @return {array} All supported languages
     */
    this.languages = () => {
      return this.request({
        url: '/languages',
        expectedCodes: [200],
        headers: {
          Accept: 'application/json',
        },
      });
    };
 
    /**
     * The main feature - check a text with LanguageTool for possible style and grammar issues.
     * @param {object} Object with query string params
     * @param queryStringParams.text {string} Text to check
     * @param queryStringParams.language {string} Language in `en-US` locale format
     * @returns {object} Validation results
     */
    this.check = queryStringParams => {
      return this.request({
        url: '/check',
        method: 'POST',
        expectedCodes: [200, 400, 500],
        qs: queryStringParams,
        headers: {
          Accept: 'application/json',
        },
      });
    };
  }
};
 
module.exports = LanguageToolClient;