33 lines
848 B
JavaScript
33 lines
848 B
JavaScript
|
describe('Fetch Module', function () {
|
||
|
|
||
|
before(() => {
|
||
|
return Edge.connect();
|
||
|
});
|
||
|
|
||
|
after(() => {
|
||
|
Edge.disconnect();
|
||
|
});
|
||
|
|
||
|
it('should fetch an authorized external url', function () {
|
||
|
var externalUrl = Edge.externalUrl("http://example.com");
|
||
|
|
||
|
return fetch(externalUrl)
|
||
|
.then(res => {
|
||
|
chai.assert.equal(res.status, 200)
|
||
|
return res.text()
|
||
|
})
|
||
|
.then(content => {
|
||
|
chai.assert.include(content, '<h1>Example Domain</h1>')
|
||
|
})
|
||
|
});
|
||
|
|
||
|
it('should not fetch an unauthorized external url', function () {
|
||
|
var externalUrl = Edge.externalUrl("https://google.com");
|
||
|
|
||
|
return fetch(externalUrl)
|
||
|
.then(res => {
|
||
|
chai.assert.equal(res.status, 403)
|
||
|
})
|
||
|
});
|
||
|
|
||
|
});
|