From 20348717640c0ef405c9fdcc8fec5b566efc48b3 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Fri, 10 Aug 2012 22:02:13 -0700 Subject: [PATCH] fix($interpolate): $interpolateProvider.endSymbol() returns startSymbol I also added missing tests. --- src/ng/interpolate.js | 2 +- test/ng/interpolateSpec.js | 54 +++++++++++++++++++++++++++++--------- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/ng/interpolate.js b/src/ng/interpolate.js index e3ba357c7ef3..06f05ed2dd43 100644 --- a/src/ng/interpolate.js +++ b/src/ng/interpolate.js @@ -45,7 +45,7 @@ function $InterpolateProvider() { endSymbol = value; return this; } else { - return startSymbol; + return endSymbol; } }; diff --git a/test/ng/interpolateSpec.js b/test/ng/interpolateSpec.js index d5f251ea3d29..88e4ae75fdbd 100644 --- a/test/ng/interpolateSpec.js +++ b/test/ng/interpolateSpec.js @@ -31,18 +31,6 @@ describe('$interpolate', function() { expect($interpolate('Hello {{name}}!')($rootScope)).toEqual('Hello Misko!'); })); - describe('provider', function() { - beforeEach(module(function($interpolateProvider) { - $interpolateProvider.startSymbol('--'); - $interpolateProvider.endSymbol('--'); - })); - - it('should not get confused with same markers', inject(function($interpolate) { - expect($interpolate('---').parts).toEqual(['---']); - expect($interpolate('----')()).toEqual(''); - expect($interpolate('--1--')()).toEqual('1'); - })); - }); describe('parseBindings', function() { it('should Parse Text With No Bindings', inject(function($interpolate) { @@ -110,4 +98,46 @@ describe('$interpolate', function() { expect(parts[2]).toEqual('C\nD"'); })); }); + + + describe('startSymbol', function() { + + beforeEach(module(function($interpolateProvider) { + expect($interpolateProvider.startSymbol()).toBe('{{'); + $interpolateProvider.startSymbol('(('); + })); + + + it('should expose the startSymbol in config phase', module(function($interpolateProvider) { + expect($interpolateProvider.startSymbol()).toBe('(('); + })); + + + it('should not get confused by matching start and end symbols', function() { + module(function($interpolateProvider) { + $interpolateProvider.startSymbol('--'); + $interpolateProvider.endSymbol('--'); + }); + + inject(function($interpolate) { + expect($interpolate('---').parts).toEqual(['---']); + expect($interpolate('----')()).toEqual(''); + expect($interpolate('--1--')()).toEqual('1'); + }); + }); + }); + + + describe('endSymbol', function() { + + beforeEach(module(function($interpolateProvider) { + expect($interpolateProvider.endSymbol()).toBe('}}'); + $interpolateProvider.endSymbol('))'); + })); + + + it('should expose the endSymbol in config phase', module(function($interpolateProvider) { + expect($interpolateProvider.endSymbol()).toBe('))'); + })); + }); });