implement this.fetch (#178)

This commit is contained in:
Rich Harris
2018-03-17 19:21:25 -04:00
parent cf6621b83c
commit 1e8d7d10ab
8 changed files with 116 additions and 1 deletions

View File

@@ -533,6 +533,32 @@ function run({ mode, basepath = '' }) {
assert.equal(title, 'Stored title');
});
});
it('sends cookies when using this.fetch with credentials: "include"', () => {
return nightmare.goto(`${base}/credentials?creds=include`)
.page.title()
.then(title => {
assert.equal(title, 'woohoo!');
});
});
it('does not send cookies when using this.fetch without credentials', () => {
return nightmare.goto(`${base}/credentials`)
.page.title()
.then(title => {
assert.equal(title, 'unauthorized');
});
});
it('delegates to fetch on the client', () => {
return nightmare.goto(base).init()
.click('[href="credentials?creds=include"]')
.wait(100)
.page.title()
.then(title => {
assert.equal(title, 'woohoo!');
});
});
});
describe('headers', () => {