-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove setUserAgent, and integrate behavior with addHeaders #7
- Loading branch information
1 parent
5e2b296
commit e9268aa
Showing
11 changed files
with
88 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { WebView } from "tns-core-modules/ui/web-view"; | ||
import { WebViewUtils } from "nativescript-webview-utils"; | ||
|
||
describe("addHeaders", () => { | ||
it("exists", () => { | ||
expect(WebViewUtils.addHeaders).toBeDefined(); | ||
}); | ||
|
||
it("fires the loadStarted and loadFinished events once", done => { | ||
// init the counters to keep track of those events | ||
let loadStartedCounter = 0; | ||
let loadFinishedCounter = 0; | ||
|
||
// create a WebView and hook up the events | ||
const webView = new WebView(); | ||
webView.on(WebView.loadStartedEvent, data => loadStartedCounter++); | ||
webView.on(WebView.loadFinishedEvent, data => loadFinishedCounter++); | ||
|
||
const headers: Map<string, string> = new Map(); | ||
headers.set("User-Agent", "My Awesome User-Agent!"); | ||
headers.set("Custom-Header", "Another header"); | ||
|
||
WebViewUtils.addHeaders(webView, headers); | ||
|
||
// load a website | ||
// (<any>webView)._loadUrl("https://httpbin.org/headers?testing=schmesting"); | ||
(<any>webView)._loadUrl("https://www.nu.nl"); | ||
|
||
setTimeout(() => { | ||
// if both events fired once, it's ok | ||
expect(loadStartedCounter).toEqual(1); | ||
expect(loadFinishedCounter).toEqual(1); | ||
done(); | ||
}, 4000); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
/// <reference path="./node_modules/tns-core-modules/tns-core-modules.d.ts" /> Needed for autocompletion and compilation. | ||
|
||
/// <reference path="./node_modules/@types/jasmine/index.d.ts" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters