DefinitelyTyped/types/http-link-header/http-link-header-tests.ts
Harris Lummis db177da108 [http-link-header] Prefer Module-Class Declaration Style (#37422)
- Change declaration style to reflect export style of js source, allow
  instantiation of module
- Fix incorrect return type on set method
- Update tests to ensure correctness of changes
2019-08-13 17:57:55 -07:00

44 lines
1.0 KiB
TypeScript

import LinkHeader = require('http-link-header');
function isLinkHeader(l: LinkHeader): null {
return null;
}
function isBool(bool: boolean): null {
return null;
}
function isReferenceArray(refArray: LinkHeader.Reference[]): null {
return null;
}
function isString(str: string): null {
return null;
}
const link = LinkHeader.parse(
'<example.com>; rel="example"; title="Example Website", ' +
'<example-twice.com>; rel="example"; title="Example Website Twice", ' +
'<example-01.com>; rel="alternate"; title="Alternate Example Domain"'
);
isReferenceArray(link.refs);
const offsetLink = LinkHeader.parse(' <example.com>; rel="example"', 1);
const has = link.has('rel', 'alternate');
isBool(has);
const get = link.get('title', 'Example Website');
isReferenceArray(get);
const rel = link.rel('alternate');
rel[0]['title'] !== 'bar';
isReferenceArray(rel);
isLinkHeader(link.set({ rel: 'next', uri: 'http://example.com/next' }));
const str = link.toString();
isString(str);
const constructedLink = new LinkHeader();