const { matchWords } = require('~/assets/javascripts/lib/helpers')

describe('#matchWords', () => {
  const data = 'Aberdeen city -'

  it('should match one letter', () => {
    expect(matchWords(data, 'b')).to.equal(true)
  })

  it('should match one word', () => {
    expect(matchWords(data, 'Aberdeen')).to.equal(true)
  })

  it('should match two words', () => {
    expect(matchWords(data, 'Aberdeen city')).to.equal(true)
  })

  it('should match lowercase', () => {
    expect(matchWords(data, 'aberdeen')).to.equal(true)
  })

  it('should match uppercase', () => {
    expect(matchWords(data, 'ABERDEEN')).to.equal(true)
  })

  it('should match uppercase and lowercase', () => {
    expect(matchWords(data, 'AbErDeEn cIty')).to.equal(true)
  })

  it('should match words in reverse order', () => {
    expect(matchWords(data, 'city Aberdeen')).to.equal(true)
  })

  it('should match words with a hyphen', () => {
    expect(matchWords(data, '-')).to.equal(true)
  })

  it('should return false if not found', () => {
    expect(matchWords(data, 'z')).to.equal(false)
  })
})

@@ -11,16 +11,33 @@
 tchWords
+, checkDateFormat
  %7D = req
@@ -1097,8 +1097,687 @@
   %7D)%0A%7D)%0A
+%0Adescribe('#checkDateFormat', () =%3E %7B%0A  context('when the date matches the required date format', () =%3E %7B%0A    it('should return true', () =%3E %7B%0A      expect(checkDateFormat('01/01/2019')).to.equal(true)%0A    %7D)%0A  %7D)%0A%0A  context('when the date does not match the required date format', () =%3E %7B%0A    it('should return false', () =%3E %7B%0A      expect(checkDateFormat('01')).to.equal(false)%0A      expect(checkDateFormat('01/')).to.equal(false)%0A      expect(checkDateFormat('01/01')).to.equal(false)%0A      expect(checkDateFormat('01/01/20')).to.equal(false)%0A      expect(checkDateFormat('aa/aa/aa')).to.equal(false)%0A      expect(checkDateFormat('2019/01/01')).to.equal(false)%0A    %7D)%0A  %7D)%0A%7D)%0A

Add test around new checkDateFormat function