Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix($interpolate): $interpolateProvider.endSymbol() returns startSymbol
Browse files Browse the repository at this point in the history
I also added missing tests.
  • Loading branch information
IgorMinar committed Aug 13, 2012
1 parent 15d283b commit 2034871
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/ng/interpolate.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function $InterpolateProvider() {
endSymbol = value;
return this;
} else {
return startSymbol;
return endSymbol;
}
};

Expand Down
54 changes: 42 additions & 12 deletions test/ng/interpolateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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('))');
}));
});
});

0 comments on commit 2034871

Please sign in to comment.