Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(465)

Side by Side Diff: remoting/webapp/unittests/apps_v2_migration_unittest.js

Issue 959963002: [Chromoting] Enable jscompile for webapp unittests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename sinon.$testStub -> sinon.TestStub Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /**
6 * @fileoverview
7 * @suppress {checkTypes|checkVars|reportUnknownTypes|visibility}
8 */
9
5 (function() { 10 (function() {
6 11
7 'use strict'; 12 'use strict';
8 13
14 /** @type {sinon.TestStub} */
9 var mockIsAppsV2 = null; 15 var mockIsAppsV2 = null;
10 var mockChromeStorage = {}; 16 var mockChromeStorage = {};
11 17
12 function pass() { 18 function pass() {
13 ok(true); 19 ok(true);
14 QUnit.start(); 20 QUnit.start();
15 } 21 }
16 22
17 function fail() { 23 function fail() {
18 ok(false); 24 ok(false);
19 QUnit.start(); 25 QUnit.start();
20 } 26 }
21 27
22 /** 28 /**
23 * @param {string} v1UserName 29 * @param {string} v1UserName
24 * @param {string} v1UserEmail 30 * @param {string} v1UserEmail
25 * @param {string} currentEmail 31 * @param {boolean} v1HasHosts
26 * @param {boolean} v1HasHost
27 */ 32 */
28 function setMigrationData_(v1UserName, v1UserEmail, v1HasHosts) { 33 function setMigrationData_(v1UserName, v1UserEmail, v1HasHosts) {
34 /** @return {!Promise} */
29 remoting.identity.getUserInfo = function() { 35 remoting.identity.getUserInfo = function() {
30 if (base.isAppsV2()) { 36 if (base.isAppsV2()) {
31 return Promise.resolve( 37 return Promise.resolve(
32 {email: 'v2user@gmail.com', name: 'v2userName'}); 38 {email: 'v2user@gmail.com', name: 'v2userName'});
33 } else { 39 } else {
34 return Promise.resolve( 40 return Promise.resolve(
35 {email: v1UserEmail, name: v1UserName}); 41 {email: v1UserEmail, name: v1UserName});
36 } 42 }
37 }; 43 };
44 /** @return {!Promise} */
38 remoting.identity.getEmail = function() { 45 remoting.identity.getEmail = function() {
39 return remoting.identity.getUserInfo().then(function(info) { 46 return remoting.identity.getUserInfo().then(
40 return info.email; 47 /** @param {{email:string, name:string}} info */
41 }); 48 function(info) {
49 return info.email;
50 });
42 }; 51 };
43 52
44 mockIsAppsV2.returns(false); 53 mockIsAppsV2.returns(false);
45 if (v1HasHosts) { 54 if (v1HasHosts) {
46 remoting.AppsV2Migration.saveUserInfo(); 55 remoting.AppsV2Migration.saveUserInfo();
47 } 56 }
48 } 57 }
49 58
50 module('AppsV2Migration', { 59 module('AppsV2Migration', {
51 setup: function() { 60 setup: function() {
52 chromeMocks.activate(['storage']); 61 chromeMocks.activate(['storage']);
53 mockIsAppsV2 = sinon.stub(base, 'isAppsV2'); 62 mockIsAppsV2 = sinon.$setupStub(base, 'isAppsV2');
54 remoting.identity = {}; 63 remoting.identity = new remoting.Identity();
55 }, 64 },
56 teardown: function() { 65 teardown: function() {
57 chromeMocks.restore(); 66 chromeMocks.restore();
58 mockIsAppsV2.restore(); 67 mockIsAppsV2.restore();
59 remoting.identity = null; 68 remoting.identity = null;
60 } 69 }
61 }); 70 });
62 71
63 QUnit.asyncTest( 72 QUnit.asyncTest(
64 'hasHostsInV1App() should reject the promise if v1 user has same identity', 73 'hasHostsInV1App() should reject the promise if v1 user has same identity',
(...skipping 17 matching lines...) Expand all
82 mockIsAppsV2.returns(false); 91 mockIsAppsV2.returns(false);
83 remoting.AppsV2Migration.hasHostsInV1App().then(fail, pass); 92 remoting.AppsV2Migration.hasHostsInV1App().then(fail, pass);
84 }); 93 });
85 94
86 QUnit.asyncTest( 95 QUnit.asyncTest(
87 'hasHostsInV1App() should return v1 identity if v1 user has hosts', 96 'hasHostsInV1App() should return v1 identity if v1 user has hosts',
88 function() { 97 function() {
89 setMigrationData_('v1userName', 'v1user@gmail.com', true); 98 setMigrationData_('v1userName', 'v1user@gmail.com', true);
90 mockIsAppsV2.returns(true); 99 mockIsAppsV2.returns(true);
91 remoting.AppsV2Migration.hasHostsInV1App().then( 100 remoting.AppsV2Migration.hasHostsInV1App().then(
101 /** @param {{email:string, name:string}} result */
92 function(result) { 102 function(result) {
93 QUnit.equal(result.email, 'v1user@gmail.com'); 103 QUnit.equal(result.email, 'v1user@gmail.com');
94 QUnit.equal(result.fullName, 'v1userName'); 104 QUnit.equal(result.fullName, 'v1userName');
95 pass(); 105 pass();
96 }, fail 106 }, fail
97 ); 107 );
98 }); 108 });
99 109
100 QUnit.asyncTest( 110 QUnit.asyncTest(
101 'saveUserInfo() should clear the preferences on v2', 111 'saveUserInfo() should clear the preferences on v2',
102 function() { 112 function() {
103 setMigrationData_('v1userName', 'v1user@gmail.com', 'v2user@gmail.com', 113 setMigrationData_('v1userName', 'v1user@gmail.com', true);
104 true);
105 mockIsAppsV2.returns(true); 114 mockIsAppsV2.returns(true);
106 remoting.AppsV2Migration.saveUserInfo(true); 115 remoting.AppsV2Migration.saveUserInfo();
107 remoting.AppsV2Migration.hasHostsInV1App().then(fail, pass); 116 remoting.AppsV2Migration.hasHostsInV1App().then(fail, pass);
108 }); 117 });
109 118
110 })(); 119 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698