From e25d4680da06621600c3bb809f5c32a70d2634e1 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Sat, 1 Aug 2015 11:31:24 -0700 Subject: [PATCH] Update formatPattern tests --- modules/__tests__/formatPattern-test.js | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/modules/__tests__/formatPattern-test.js b/modules/__tests__/formatPattern-test.js index bdd30f1982..1ba10b081e 100644 --- a/modules/__tests__/formatPattern-test.js +++ b/modules/__tests__/formatPattern-test.js @@ -1,9 +1,9 @@ import expect from 'expect'; -import { formatPattern } from '../URLUtils'; +import { formatPattern } from '../PatternUtils'; describe('formatPattern', function () { describe('when a pattern does not have dynamic segments', function () { - var pattern = 'a/b/c'; + var pattern = '/a/b/c'; it('returns the pattern', function () { expect(formatPattern(pattern, {})).toEqual(pattern); @@ -11,7 +11,7 @@ describe('formatPattern', function () { }); describe('when a pattern has dynamic segments', function () { - var pattern = 'comments/:id/edit'; + var pattern = '/comments/:id/edit'; describe('and a param is missing', function () { it('throws an Error', function () { @@ -22,60 +22,60 @@ describe('formatPattern', function () { }); describe('and a param is optional', function () { - var pattern = 'comments/(:id)/edit'; + var pattern = '/comments/(:id)/edit'; it('returns the correct path when param is supplied', function () { - expect(formatPattern(pattern, { id:'123' })).toEqual('comments/123/edit'); + expect(formatPattern(pattern, { id:'123' })).toEqual('/comments/123/edit'); }); it('returns the correct path when param is not supplied', function () { - expect(formatPattern(pattern, {})).toEqual('comments/edit'); + expect(formatPattern(pattern, {})).toEqual('/comments/edit'); }); }); describe('and a param and forward slash are optional', function () { - var pattern = 'comments(/:id)/edit'; + var pattern = '/comments(/:id)/edit'; it('returns the correct path when param is supplied', function () { - expect(formatPattern(pattern, { id:'123' })).toEqual('comments/123/edit'); + expect(formatPattern(pattern, { id:'123' })).toEqual('/comments/123/edit'); }); it('returns the correct path when param is not supplied', function () { - expect(formatPattern(pattern, {})).toEqual('comments/edit'); + expect(formatPattern(pattern, {})).toEqual('/comments/edit'); }); }); describe('and all params are present', function () { it('returns the correct path', function () { - expect(formatPattern(pattern, { id: 'abc' })).toEqual('comments/abc/edit'); + expect(formatPattern(pattern, { id: 'abc' })).toEqual('/comments/abc/edit'); }); it('returns the correct path when the value is 0', function () { - expect(formatPattern(pattern, { id: 0 })).toEqual('comments/0/edit'); + expect(formatPattern(pattern, { id: 0 })).toEqual('/comments/0/edit'); }); }); describe('and some params have special URL encoding', function () { it('returns the correct path', function () { - expect(formatPattern(pattern, { id: 'one, two' })).toEqual('comments/one%2C+two/edit'); + expect(formatPattern(pattern, { id: 'one, two' })).toEqual('/comments/one%2C+two/edit'); }); }); describe('and a param has a forward slash', function () { it('preserves the forward slash', function () { - expect(formatPattern(pattern, { id: 'the/id' })).toEqual('comments/the%2Fid/edit'); + expect(formatPattern(pattern, { id: 'the/id' })).toEqual('/comments/the%2Fid/edit'); }); }); describe('and some params contain dots', function () { it('returns the correct path', function () { - expect(formatPattern(pattern, { id: 'alt.black.helicopter' })).toEqual('comments/alt.black.helicopter/edit'); + expect(formatPattern(pattern, { id: 'alt.black.helicopter' })).toEqual('/comments/alt.black.helicopter/edit'); }); }); describe('and some params contain special characters', function () { it('returns the correct path', function () { - expect(formatPattern(pattern, { id: '?not=confused&with=query#string' })).toEqual('comments/%3Fnot%3Dconfused%26with%3Dquery%23string/edit'); + expect(formatPattern(pattern, { id: '?not=confused&with=query#string' })).toEqual('/comments/%3Fnot%3Dconfused%26with%3Dquery%23string/edit'); }); }); });