repo_description: BDD style assertions for node.js -- test framework agnostic
repo_topics: assertions bdd javascript node-js should tdd test testing tests
code: /*
   * should.js - assertion library
   * Copyright(c) 2010-2013 TJ Holowaychuk <[REDACTED_EMAIL]>
   * Copyright(c) 2013-2017 Denis Bardadym <[REDACTED_EMAIL]>
   * MIT Licensed
   */
  
  export default function(should, Assertion) {
    /**
     * Assert given string starts with prefix
     * @name startWith
     * @memberOf Assertion
     * @category assertion strings
     * @param {string} str Prefix
     * @param {string} [description] Optional message
     * @example
     *
     * 'abc'.should.startWith('a');
     */
    Assertion.add("startWith", function(str, description) {
      this.params = {
        operator: "to start with " + should.format(str),
        message: description
      };
  
      this.assert(0 === this.obj.indexOf(str));
    });
  
    /**
     * Assert given string ends with prefix
     * @name endWith
     * @memberOf Assertion
     * @category assertion strings
     * @param {string} str Prefix
     * @param {string} [description] Optional message
     * @example
     *
     * 'abca'.should.endWith('a');
     */
    Assertion.add("endWith", function(str, description) {
      this.params = {
        operator: "to end with " + should.format(str),
        message: description
      };
  
      this.assert(this.obj.indexOf(str, this.obj.length - str.length) >= 0);
    });
  }
  