JenMorgan / js-learning

0 stars 0 forks source link

harmlessRansomNote #48

Open kartamyshev opened 4 years ago

kartamyshev commented 4 years ago
/**
 * Function checks if there are enough
 * words in magazine to craete the note
 *
 * @param {String} noteText
 * @param {String} magazineText
 * @returns {Boolean}
 */
function harmlessRansomNote(noteText, magazineText) {

}
// test cases

describe('harmlessRansomNote', () => {
  it(`returns false if there are words in "note" that are not present in magazine `, () => {
    const noteText = 'this is a secret note for you from a secret admirer';
    const magazineText = `puerto rico is a great place you must hike far from town to find a secret waterfall that i am an admirer of but note that it is not as hard as it seems this is my advice for you`;

    const actual = harmlessRansomNote(noteText, magazineText);
    expect(actual).toEqual(false);
  });

  it(`returns true if all the words in "note" present in magazine `, () => {
    const noteText = 'this is a note for you from a secret admirer';
    const magazineText = `puerto rico is a great place you must hike far from town to find a secret waterfall that i am an admirer of but note that it is not as hard as it seems this is my advice for you`;

    const actual = harmlessRansomNote(noteText, magazineText);
    expect(actual).toEqual(true);
  });

  it('returns false if there are not enough words in magazine to craete the note', () => {
    const actual = harmlessRansomNote('one two three', 'one note two notes');

    expect(actual).toEqual(false);
  });

  it('returns true if there are enough words in magazine to craete the note', () => {
    const actual = harmlessRansomNote('one two three', 'one note two notes three notes');

    expect(actual).toEqual(true);
  });
});