本文整理汇总了TypeScript中angular2/src/http/url_search_params.URLSearchParams.has方法的典型用法代码示例。如果您正苦于以下问题:TypeScript URLSearchParams.has方法的具体用法?TypeScript URLSearchParams.has怎么用?TypeScript URLSearchParams.has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/src/http/url_search_params.URLSearchParams
的用法示例。
在下文中一共展示了URLSearchParams.has方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should support multimap-like merging operation via replaceAll()', () => {
var mapA = new URLSearchParams('a=1&a=2&a=3&c=8');
var mapB = new URLSearchParams('a=4&a=5&a=6&b=7');
mapA.replaceAll(mapB);
expect(mapA.has('a')).toBe(true);
expect(mapA.has('b')).toBe(true);
expect(mapA.has('c')).toBe(true);
expect(mapA.getAll('a')).toEqual(['4', '5', '6']);
expect(mapA.getAll('b')).toEqual(['7']);
expect(mapA.getAll('c')).toEqual(['8']);
expect(mapA.toString()).toEqual('a=4&a=5&a=6&c=8&b=7');
});
示例2: it
it('should conform to spec', () => {
var paramsString = "q=URLUtils.searchParams&topic=api";
var searchParams = new URLSearchParams(paramsString);
// Tests borrowed from example at
// https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
// Compliant with spec described at https://url.spec.whatwg.org/#urlsearchparams
expect(searchParams.has("topic")).toBe(true);
expect(searchParams.has("foo")).toBe(false);
expect(searchParams.get("topic")).toBe("api");
expect(searchParams.getAll("topic")).toEqual(["api"]);
expect(searchParams.get("foo")).toBe(null);
searchParams.append("topic", "webdev");
expect(searchParams.getAll("topic")).toEqual(["api", "webdev"]);
expect(searchParams.toString()).toBe("q=URLUtils.searchParams&topic=api&topic=webdev");
searchParams.delete("topic");
expect(searchParams.toString()).toBe("q=URLUtils.searchParams");
});
示例3: it
it('should conform to spec', () => {
var paramsString = 'q=URLUtils.searchParams&topic=api';
var searchParams = new URLSearchParams(paramsString);
// Tests borrowed from example at
// https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
// Compliant with spec described at https://url.spec.whatwg.org/#urlsearchparams
expect(searchParams.has('topic')).toBe(true);
expect(searchParams.has('foo')).toBe(false);
expect(searchParams.get('topic')).toEqual('api');
expect(searchParams.getAll('topic')).toEqual(['api']);
expect(searchParams.get('foo')).toBe(null);
searchParams.append('topic', 'webdev');
expect(searchParams.getAll('topic')).toEqual(['api', 'webdev']);
expect(searchParams.toString()).toEqual('q=URLUtils.searchParams&topic=api&topic=webdev');
searchParams.delete('topic');
expect(searchParams.toString()).toEqual('q=URLUtils.searchParams');
// Test default constructor
expect(new URLSearchParams().toString()).toBe('');
});