Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Morten Barklund committed Dec 20, 2022
1 parent afff7fc commit 913d571
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/url/src/test/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* Internal dependencies
*/
import { withProtocol, isValidUrl } from '..';
import { withProtocol, isValidUrl, withoutProtocol } from '..';

describe('isValidUrl', () => {
it('should return correct results for valid URL', () => {
Expand All @@ -35,14 +35,16 @@ describe('isValidUrl', () => {

describe('withProtocol', () => {
it('should add protocol correctly if applicable', () => {
expect(withProtocol('https://foo-bar.com/test.jpg')).toBe(
'https://foo-bar.com/test.jpg'
);
expect(withProtocol('http://foo-bar.com/test.jpg')).toBe(
'http://foo-bar.com/test.jpg'
);
expect(withProtocol('foo-bar.com/test.jpg')).toBe(
'https://foo-bar.com/test.jpg'
);
expect(withProtocol('https://foo.com/test')).toBe('https://foo.com/test');
expect(withProtocol('http://foo.com/test')).toBe('http://foo.com/test');
expect(withProtocol('foo.com/test')).toBe('https://foo.com/test');
});
});

describe('withoutProtocol', () => {
it('should remove protocol correctly if applicable', () => {
expect(withoutProtocol('https://foo.com/test')).toBe('foo.com/test');
expect(withoutProtocol('http://foo.com/test')).toBe('foo.com/test');
expect(withoutProtocol('foo.com/test')).toBe('foo.com/test');
});
});

0 comments on commit 913d571

Please sign in to comment.