|
/* eslint-env mocha */ |
|
/* global expect, sinon */ |
|
import formatUkPhone from './format-uk-phone'; |
|
|
|
describe('formatUkPhone', () => { |
|
it('should exist', () => { |
|
expect(formatUkPhone).to.be.ok; |
|
}); |
|
|
|
it('should match the format for numbers beginning with 01', () => { |
|
const val = '0122222222'; |
|
expect(formatUkPhone(val)).to.equal('01222 22222'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 011#', () => { |
|
const val = '0112222222'; |
|
expect(formatUkPhone(val)).to.equal('0112 222 222'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 011#', () => { |
|
const val = '0121222222'; |
|
expect(formatUkPhone(val)).to.equal('0121 222 222'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 013873', () => { |
|
const val = '01387312345'; |
|
expect(formatUkPhone(val)).to.equal('013873 12345'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 015242', () => { |
|
const val = '01524212345'; |
|
expect(formatUkPhone(val)).to.equal('015242 12345'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 015394', () => { |
|
const val = '01539412345'; |
|
expect(formatUkPhone(val)).to.equal('015394 12345'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 015395', () => { |
|
const val = '01539512345'; |
|
expect(formatUkPhone(val)).to.equal('015395 12345'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 015396', () => { |
|
const val = '01539612345'; |
|
expect(formatUkPhone(val)).to.equal('015396 12345'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 016973', () => { |
|
const val = '01697312345'; |
|
expect(formatUkPhone(val)).to.equal('016973 12345'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 016974', () => { |
|
const val = '01697412345'; |
|
expect(formatUkPhone(val)).to.equal('016974 12345'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 016977', () => { |
|
const val = '01697712345'; |
|
expect(formatUkPhone(val)).to.equal('016977 12345'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 017683', () => { |
|
const val = '01768312345'; |
|
expect(formatUkPhone(val)).to.equal('017683 12345'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 017684', () => { |
|
const val = '01768412345'; |
|
expect(formatUkPhone(val)).to.equal('017684 12345'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 017687', () => { |
|
const val = '01768712345'; |
|
expect(formatUkPhone(val)).to.equal('017687 12345'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 019467', () => { |
|
const val = '01946712345'; |
|
expect(formatUkPhone(val)).to.equal('019467 12345'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 02', () => { |
|
const val = '02123456789'; |
|
expect(formatUkPhone(val)).to.equal('021 2345 6789'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 03', () => { |
|
const val = '03123456789'; |
|
expect(formatUkPhone(val)).to.equal('0312 345 6789'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 05', () => { |
|
const val = '05123456789'; |
|
expect(formatUkPhone(val)).to.equal('05123 456789'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 07', () => { |
|
const val = '07123456789'; |
|
expect(formatUkPhone(val)).to.equal('07123 456789'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 08', () => { |
|
const val = '08123456789'; |
|
expect(formatUkPhone(val)).to.equal('0812 345 6789'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 0800', () => { |
|
const val = '0800123456'; |
|
expect(formatUkPhone(val)).to.equal('0800 123456'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 09', () => { |
|
const val = '09123456789'; |
|
expect(formatUkPhone(val)).to.equal('0912 345 6789'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 44', () => { |
|
const val = '442079460018'; |
|
expect(formatUkPhone(val)).to.equal('+44 20 7946 0018'); |
|
}); |
|
|
|
it('should match the format for numbers beginning with 44', () => { |
|
const val = '00442079460018'; |
|
expect(formatUkPhone(val)).to.equal('+44 20 7946 0018'); |
|
}); |
|
|
|
it('should return the original string if no match is found', () => { |
|
const val = '04123456789'; |
|
expect(formatUkPhone(val)).to.equal('04123456789'); |
|
}); |
|
}); |