only replace components for changed segments

This commit is contained in:
Rich Harris
2018-07-17 15:42:35 -04:00
parent 84aaf3be4a
commit f126c6ac6c
7 changed files with 180 additions and 19 deletions

View File

@@ -632,6 +632,33 @@ function run({ mode, basepath = '' }) {
assert.equal(html.indexOf('%sapper'), -1);
});
});
it('only recreates components when necessary', () => {
return nightmare
.goto(`${base}/foo/bar/baz`)
.init()
.evaluate(() => document.querySelector('#sapper').textContent)
.then(text => {
assert.deepEqual(text.split('\n').filter(Boolean), [
'x: foo 1',
'y: bar 1',
'z: baz 1'
]);
return nightmare.click(`a`)
.then(() => wait(100))
.then(() => {
return nightmare.evaluate(() => document.querySelector('#sapper').textContent);
});
})
.then(text => {
assert.deepEqual(text.split('\n').filter(Boolean), [
'x: foo 1',
'y: bar 1',
'z: qux 2'
]);
});
});
});
describe('headers', () => {