Files
edx-platform/common/static/js/spec/utility_spec.js
Julia Hansbrough 079808ee47 Revert "Merge pull request #4545 from edx/renzo/bi-analytics-overhaul"
This reverts commit 252038c376, reversing
changes made to 7caf8c53b1.
2014-07-29 17:41:46 +00:00

19 lines
999 B
JavaScript

describe('utility.rewriteStaticLinks', function () {
it('returns "content" if "from" or "to" is null', function () {
expect(rewriteStaticLinks('foo', null, 'bar')).toBe('foo');
expect(rewriteStaticLinks('foo', 'bar', null)).toBe('foo');
expect(rewriteStaticLinks('foo', null, null)).toBe('foo');
});
it('does a replace of "from" to "to"', function () {
expect(rewriteStaticLinks('<img src="/static/foo.x"/>', '/static/', 'howdy')).toBe('<img src="howdyfoo.x"/>')
});
it('returns "content" if "from" is not found', function () {
expect(rewriteStaticLinks('<img src="/static/foo.x"/>', '/statix/', 'howdy')).toBe('<img src="/static/foo.x"/>')
});
it('does not replace of "from" to "to" if "from" is part of absolute url', function () {
expect(
rewriteStaticLinks('<img src="http://www.mysite.org/static/foo.x"/>', '/static/', 'howdy')
).toBe('<img src="http://www.mysite.org/static/foo.x"/>')
});
});