utility_spec.js 997 Bytes
Newer Older
1 2
describe('utility.rewriteStaticLinks', function() {
    it('returns "content" if "from" or "to" is null', function() {
3 4 5 6
        expect(rewriteStaticLinks('foo', null, 'bar')).toBe('foo');
        expect(rewriteStaticLinks('foo', 'bar', null)).toBe('foo');
        expect(rewriteStaticLinks('foo', null, null)).toBe('foo');
    });
7 8
    it('does a replace of "from" to "to"', function() {
        expect(rewriteStaticLinks('<img src="/static/foo.x"/>', '/static/', 'howdy')).toBe('<img src="howdyfoo.x"/>');
9
    });
10 11
    it('returns "content" if "from" is not found', function() {
        expect(rewriteStaticLinks('<img src="/static/foo.x"/>', '/statix/', 'howdy')).toBe('<img src="/static/foo.x"/>');
12
    });
13
    it('does not replace of "from" to "to" if "from" is part of absolute url', function() {
14 15
        expect(
            rewriteStaticLinks('<img src="http://www.mysite.org/static/foo.x"/>', '/static/', 'howdy')
16
        ).toBe('<img src="http://www.mysite.org/static/foo.x"/>');
17
    });
18
});