Files
rrweb/test/snapshot.test.ts
Yanzhen Yu 216d03dae3 Fix the regexp performance issue
Also move the addHoverClass implementation into the rebuild stage.
So if there is still some corner case we have not handled, it will
only affect the replayer part of rrweb.
2018-11-01 11:36:25 +08:00

32 lines
873 B
TypeScript

import 'mocha';
import { expect } from 'chai';
import { absoluteToStylesheet } from '../src/snapshot';
describe('absolute url to stylesheet', () => {
const href = 'http://localhost/css/style.css';
it('can handle same level path', () => {
expect(absoluteToStylesheet('url("./a.jpg")', href)).to.equal(
`url('http://localhost/css/a.jpg')`,
);
});
it('can handle parent level path', () => {
expect(absoluteToStylesheet('url("../a.jpg")', href)).to.equal(
`url('http://localhost/a.jpg')`,
);
});
it('can handle absolute path', () => {
expect(absoluteToStylesheet('url("/a.jpg")', href)).to.equal(
`url('http://localhost/a.jpg')`,
);
});
it('can handle external path', () => {
expect(
absoluteToStylesheet('url("http://localhost/a.jpg")', href),
).to.equal(`url('http://localhost/a.jpg')`);
});
});