import { expect } from 'chai' import { polyfill } from '../mod.js' describe('Fetch', () => { const target = {} before(() => polyfill(target)) it('Fetch functionality', () => { expect(target).to.have.property('fetch').that.is.a('function') }) it('Fetch with https', async () => { const { fetch } = target const response = await fetch('https://api.openbrewerydb.org/breweries') expect(response.constructor).to.equal(target.Response) const json = await response.json() expect(json).to.be.an('array') }) it('Fetch with file', async () => { const { fetch } = target const url = new URL('../package.json', import.meta.url) const response = await fetch(url) expect(response.constructor).to.equal(target.Response) expect(response.status).to.equal(200) expect(response.statusText).to.be.empty expect(response.headers.has('date')).to.equal(true) expect(response.headers.has('content-length')).to.equal(true) expect(response.headers.has('last-modified')).to.equal(true) const json = await response.json() expect(json.name).to.equal('@astrojs/webapi') }) it('Fetch with missing file', async () => { const { fetch } = target const url = new URL('../missing.json', import.meta.url) const response = await fetch(url) expect(response.constructor).to.equal(target.Response) expect(response.status).to.equal(404) expect(response.statusText).to.be.empty expect(response.headers.has('date')).to.equal(true) expect(response.headers.has('content-length')).to.equal(false) expect(response.headers.has('last-modified')).to.equal(false) }) it('Fetch with (file) Request', async () => { const { Request, fetch } = target const request = new Request(new URL('../package.json', import.meta.url)) const response = await fetch(request) expect(response.constructor).to.equal(target.Response) const json = await response.json() expect(json.name).to.equal('@astrojs/webapi') }) it('Fetch with relative file', async () => { const { fetch } = target const response = await fetch('package.json') const json = await response.json() expect(json.name).to.equal('@astrojs/webapi') }) it('Fetch with data', async () => { const { fetch } = target const jsonURI = `data:application/json,${encodeURIComponent( JSON.stringify({ name: '@astrojs/webapi', }) )}` const response = await fetch(jsonURI) const json = await response.json() expect(json.name).to.equal('@astrojs/webapi') }) }) ='sub right'>
aboutsummaryrefslogtreecommitdiff
path: root/test (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2016-10-19releasing 002Gravatar Miek Gieben 2-2/+2
2016-10-19middleware/file: fix DS handling (#344)Gravatar Miek Gieben 4-0/+227
The DS record is handled specially in the server ServeDNS mux, but there was no code that actually called the correct middleware handler chain when encountering a DS. This PR fixes that behavoir, additonal bugs has been files to look into how we are handling delegation (secure and non-secure ones).
2016-10-18Add `cache_capacity` option to dnssec middleware for the capacity of LRU ↵Gravatar Yong Tang 3-30/+58
cache (#339) This fix adds a `cache_capacity` option to dnssec middleware, so that it is possible to specify the capacity of the LRU cache used by dnssec middleware. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-18middleware/etcd: more tests (#342)Gravatar Miek Gieben 2-1/+93
Add a test which enables caching and debug queries and make sure the debug query does not overwrite the cache.
2016-10-18Documentation updates (#340)Gravatar Miek Gieben 2-22/+41
2016-10-18We dont support log rotation anymoreGravatar Miek Gieben 1-14/+0
2016-10-17Small golint cleanup. (#338)Gravatar Yong Tang 1-1/+1
A small golint cleanup. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-17middleware/auto: add (#333)Gravatar Miek Gieben 19-18/+838
Add auto-load middleware that automatically picks up zones. Every X seconds it will scan for new zones. Add tests and documentation. Make 'make test' use -race.
2016-10-17Fix files reload failure within a single root zone. (#337)Gravatar Zhipeng JIANG 1-4/+5
In the file middleware, if there are multiple zone files under a single root zone, watchers are only invoked on the last element of `zones.Names`. This is caused by loop override on the variable `n`. This issue can be fixed by passing zone object, which calls reload watcher directly.
2016-10-17Replace go-cache with golang-lru in dnssec (#336)Gravatar Yong Tang 5-16/+27
* Replace go-cache with golang-lru This fix replace go-cache with golang-lru, as is specified in 335. Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Move cache initialization to setup This commit move cache initialization to setup in dnssec middleware. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-17Check for empty message in typifyGravatar Miek Gieben 2-0/+13
2016-10-17middleware.md: put in the same docGravatar Miek Gieben 2-25/+29
Move middleware/middleware.md to middleware.md. This should be the canonical place where to document how middlewares should look and act.
2016-10-14Add needed comments for `golint` cleanup. (#334)Gravatar Yong Tang 1-6/+10
This fix adds several needed comments in `middleware/kubernetes/nametemplate/nametemplate.go` to clean up golint output. There are still 3 places that needs proper docs: ``` middleware/kubernetes/nametemplate/nametemplate.go:64:1: comment on exported type Template should be of the form "Template ..." (with optional leading article) middleware/kubernetes/nametemplate/nametemplate.go:72:1: comment on exported method Template.SetTemplate should be of the form "SetTemplate ..." middleware/kubernetes/nametemplate/nametemplate.go:188:1: comment on exported type NameValues should be of the form "NameValues ..." (with optional leading article) ``` Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-12cleanups: go vet/golint (#331)Gravatar Miek Gieben 16-64/+64
Go vet and golint the new code once again. Drop Name from NameTemplate - it's cleaner: nametemplate.Template.
2016-10-11middleware/root: add it (#330)Gravatar Miek Gieben 10-3/+184
This PR adds the *root* middleware that specifies a path where all zone file (the *file* middleware is the only consumer now) can be found. It works the same as in Caddy. Documentation can be found in the README.md of the middleware. Fixes #307