|
1 | 1 | if (typeof define !== 'function') { |
2 | 2 | var define = require('amdefine')(module); |
3 | 3 | } |
4 | | -define([ 'require', './src/authorize', 'fs'], function(require, Authorize, fs) { |
| 4 | +define([ 'require', './src/authorize', './src/config'], function(require, Authorize, config) { |
5 | 5 | var suites = []; |
6 | 6 |
|
7 | 7 | suites.push({ |
@@ -82,16 +82,42 @@ define([ 'require', './src/authorize', 'fs'], function(require, Authorize, fs) { |
82 | 82 | } |
83 | 83 | }, |
84 | 84 |
|
| 85 | + { |
| 86 | + desc: "Authorize doesn't redirect, but opens an in-app-browser window", |
| 87 | + run: function(env, test) { |
| 88 | + document.location.href = 'file:///some/cordova/path'; |
| 89 | + var authUrl = 'http://storage.provider.com/oauth'; |
| 90 | + var scope = 'contacts:r'; |
| 91 | + var redirectUri = 'http://awesome.app.com/#'; |
| 92 | + var clientId = 'http://awesome.app.com/'; |
| 93 | + |
| 94 | + global.cordova = { foo: 'bar' }; // Pretend we run in Cordova |
| 95 | + |
| 96 | + this.localStorageAvailable = function() { return true; }; |
| 97 | + |
| 98 | + Authorize.openWindow = function(url, uri) { |
| 99 | + test.assertAnd(uri, redirectUri); |
| 100 | + test.done(); |
| 101 | + }; |
| 102 | + |
| 103 | + Authorize(this, authUrl, scope, redirectUri, clientId); |
| 104 | + |
| 105 | + test.assertAnd(document.location.href, 'file:///some/cordova/path'); |
| 106 | + } |
| 107 | + }, |
| 108 | + |
85 | 109 | { |
86 | 110 | desc: "document.location getter", |
87 | 111 | run: function(env, test) { |
| 112 | + document.location.href = 'http://foo/bar'; |
88 | 113 | test.assert(Authorize.getLocation().href, "http://foo/bar"); |
89 | 114 | } |
90 | 115 | }, |
91 | 116 |
|
92 | 117 | { |
93 | 118 | desc: "document.location setter", |
94 | 119 | run: function(env, test) { |
| 120 | + document.location.href = 'http://foo/bar'; |
95 | 121 | Authorize.setLocation("https://bar/foo"); |
96 | 122 | test.assert(Authorize.getLocation().href, "https://bar/foo"); |
97 | 123 | } |
|
0 commit comments