2015-09-11 16:37:05 -04:00
|
|
|
import {
|
|
|
|
AsyncTestCompleter,
|
|
|
|
beforeEach,
|
|
|
|
ddescribe,
|
|
|
|
describe,
|
|
|
|
el,
|
|
|
|
expect,
|
|
|
|
iit,
|
|
|
|
inject,
|
|
|
|
it,
|
|
|
|
xit,
|
|
|
|
TestComponentBuilder
|
2015-10-13 03:29:13 -04:00
|
|
|
} from 'angular2/testing_internal';
|
2015-09-11 16:37:05 -04:00
|
|
|
|
2015-11-06 20:34:07 -05:00
|
|
|
import {IS_DART} from 'angular2/src/facade/lang';
|
2015-11-05 17:07:57 -05:00
|
|
|
import {escapeSingleQuoteString, escapeDoubleQuoteString} from 'angular2/src/compiler/util';
|
2015-09-11 16:37:05 -04:00
|
|
|
|
|
|
|
export function main() {
|
|
|
|
describe('util', () => {
|
|
|
|
describe('escapeSingleQuoteString', () => {
|
|
|
|
it('should escape single quotes',
|
|
|
|
() => { expect(escapeSingleQuoteString(`'`)).toEqual(`'\\''`); });
|
|
|
|
|
|
|
|
it('should escape backslash',
|
|
|
|
() => { expect(escapeSingleQuoteString('\\')).toEqual(`'\\\\'`); });
|
|
|
|
|
|
|
|
it('should escape newlines',
|
|
|
|
() => { expect(escapeSingleQuoteString('\n')).toEqual(`'\\n'`); });
|
2015-09-18 13:33:23 -04:00
|
|
|
|
|
|
|
if (IS_DART) {
|
|
|
|
it('should escape $', () => { expect(escapeSingleQuoteString('$')).toEqual(`'\\$'`); });
|
|
|
|
} else {
|
|
|
|
it('should not escape $', () => { expect(escapeSingleQuoteString('$')).toEqual(`'$'`); });
|
|
|
|
}
|
2015-09-11 16:37:05 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('escapeDoubleQuoteString', () => {
|
|
|
|
it('should escape double quotes',
|
|
|
|
() => { expect(escapeDoubleQuoteString(`"`)).toEqual(`"\\""`); });
|
|
|
|
|
|
|
|
it('should escape backslash',
|
|
|
|
() => { expect(escapeDoubleQuoteString('\\')).toEqual(`"\\\\"`); });
|
|
|
|
|
|
|
|
it('should escape newlines',
|
|
|
|
() => { expect(escapeDoubleQuoteString('\n')).toEqual(`"\\n"`); });
|
2015-09-18 13:33:23 -04:00
|
|
|
|
|
|
|
if (IS_DART) {
|
|
|
|
it('should escape $', () => { expect(escapeDoubleQuoteString('$')).toEqual(`"\\$"`); });
|
|
|
|
} else {
|
|
|
|
it('should not escape $', () => { expect(escapeDoubleQuoteString('$')).toEqual(`"$"`); });
|
|
|
|
}
|
2015-09-11 16:37:05 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
2015-10-02 10:57:29 -04:00
|
|
|
}
|