Skip to content

Commit 8a66198

Browse files
committed
Formatting
1 parent ec29232 commit 8a66198

File tree

5 files changed

+118
-13
lines changed

5 files changed

+118
-13
lines changed

packages-exp/auth-exp/scripts/run-node-tests.js

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"use strict";
1+
'use strict';
22
/**
33
* @license
44
* Copyright 2020 Google LLC
@@ -14,4 +14,71 @@
1414
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
17-
*/var __spreadArrays=this&&this.__spreadArrays||function(){for(var s=0,i=0,il=arguments.length;i<il;i++)s+=arguments[i].length;for(var r=Array(s),k=0,i=0;i<il;i++)for(var a=arguments[i],j=0,jl=a.length;j<jl;j++,k++)r[k]=a[j];return r};exports.__esModule=true;var path_1=require("path");var child_process_promise_1=require("child-process-promise");var yargs=require("yargs");var argv=yargs.options({local:{type:"boolean"},integration:{type:"boolean"},webdriver:{type:"boolean"}}).argv;var nyc=path_1.resolve(__dirname,"../../../node_modules/.bin/nyc");var mocha=path_1.resolve(__dirname,"../../../node_modules/.bin/mocha");process.env.TS_NODE_COMPILER_OPTIONS='{"module":"commonjs", "target": "es6"}';var testConfig=["src/!(platform_browser|platform_react_native|platform_cordova)/**/*.test.ts","--file","index.node.ts"];if(argv.integration){testConfig=["test/integration/flows/{email,anonymous}.test.ts"];if(argv.local){testConfig.push("test/integration/flows/*.local.test.ts")}}else if(argv.webdriver){testConfig=["test/integration/webdriver/**.test.ts","--delay"]}var args=__spreadArrays(["--reporter","lcovonly",mocha],testConfig,["--config","../../config/mocharc.node.js"]);if(argv.local){if(!process.env.GCLOUD_PROJECT||!process.env.FIREBASE_AUTH_EMULATOR_HOST){console.error("Local testing against emulator requested, but "+"GCLOUD_PROJECT and FIREBASE_AUTH_EMULATOR_HOST env variables "+"are missing");process.exit(1)}}args=args.concat(argv._);var spawned=child_process_promise_1.spawn(nyc,args,{stdio:"inherit",cwd:process.cwd()});var childProcess=spawned.childProcess;spawned["catch"]((function(){childProcess.kill();process.exit(1)}));process.once("exit",(function(){return childProcess.kill()}));process.once("SIGINT",(function(){return childProcess.kill("SIGINT")}));process.once("SIGTERM",(function(){return childProcess.kill("SIGTERM")}));
17+
*/ var __spreadArrays =
18+
(this && this.__spreadArrays) ||
19+
function () {
20+
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
21+
s += arguments[i].length;
22+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
23+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
24+
r[k] = a[j];
25+
return r;
26+
};
27+
exports.__esModule = true;
28+
var path_1 = require('path');
29+
var child_process_promise_1 = require('child-process-promise');
30+
var yargs = require('yargs');
31+
var argv = yargs.options({
32+
local: { type: 'boolean' },
33+
integration: { type: 'boolean' },
34+
webdriver: { type: 'boolean' }
35+
}).argv;
36+
var nyc = path_1.resolve(__dirname, '../../../node_modules/.bin/nyc');
37+
var mocha = path_1.resolve(__dirname, '../../../node_modules/.bin/mocha');
38+
process.env.TS_NODE_COMPILER_OPTIONS = '{"module":"commonjs", "target": "es6"}';
39+
var testConfig = [
40+
'src/!(platform_browser|platform_react_native|platform_cordova)/**/*.test.ts',
41+
'--file',
42+
'index.node.ts'
43+
];
44+
if (argv.integration) {
45+
testConfig = ['test/integration/flows/{email,anonymous}.test.ts'];
46+
if (argv.local) {
47+
testConfig.push('test/integration/flows/*.local.test.ts');
48+
}
49+
} else if (argv.webdriver) {
50+
testConfig = ['test/integration/webdriver/**.test.ts', '--delay'];
51+
}
52+
var args = __spreadArrays(['--reporter', 'lcovonly', mocha], testConfig, [
53+
'--config',
54+
'../../config/mocharc.node.js'
55+
]);
56+
if (argv.local) {
57+
if (!process.env.GCLOUD_PROJECT || !process.env.FIREBASE_AUTH_EMULATOR_HOST) {
58+
console.error(
59+
'Local testing against emulator requested, but ' +
60+
'GCLOUD_PROJECT and FIREBASE_AUTH_EMULATOR_HOST env variables ' +
61+
'are missing'
62+
);
63+
process.exit(1);
64+
}
65+
}
66+
args = args.concat(argv._);
67+
var spawned = child_process_promise_1.spawn(nyc, args, {
68+
stdio: 'inherit',
69+
cwd: process.cwd()
70+
});
71+
var childProcess = spawned.childProcess;
72+
spawned['catch'](function () {
73+
childProcess.kill();
74+
process.exit(1);
75+
});
76+
process.once('exit', function () {
77+
return childProcess.kill();
78+
});
79+
process.once('SIGINT', function () {
80+
return childProcess.kill('SIGINT');
81+
});
82+
process.once('SIGTERM', function () {
83+
return childProcess.kill('SIGTERM');
84+
});

packages-exp/auth-exp/test/integration/webdriver/redirect.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
// eslint-disable-next-line import/no-extraneous-dependencies
1919
import { OperationType, UserCredential } from '@firebase/auth-exp';
2020
import { expect } from 'chai';
21-
import { TestFunction, } from './util/auth_driver';
21+
import { TestFunction } from './util/auth_driver';
2222
import { IdPPage } from './util/idp_page';
2323
import { browserDescribe } from './util/test_runner';
2424

2525
browserDescribe('WebDriver redirect IdP test', driver => {
2626
it('allows users to sign in', async () => {
27-
await driver.pause(200); // Race condition on auth init
27+
await driver.pause(200); // Race condition on auth init
2828
await driver.callNoWait(TestFunction.IDP_REDIRECT);
2929
const widget = new IdPPage(driver.webDriver);
3030

@@ -38,14 +38,16 @@ browserDescribe('WebDriver redirect IdP test', driver => {
3838
await widget.clickSignIn();
3939

4040
await driver.reinitOnRedirect();
41-
41+
4242
const currentUser = await driver.getUserSnapshot();
4343
expect(currentUser.email).to.eq('[email protected]');
4444
expect(currentUser.displayName).to.eq('Bob Test');
4545
expect(currentUser.photoURL).to.eq('bob.test/bob');
4646

47-
const redirectResult: UserCredential = await driver.call(TestFunction.REDIRECT_RESULT);
47+
const redirectResult: UserCredential = await driver.call(
48+
TestFunction.REDIRECT_RESULT
49+
);
4850
expect(redirectResult.operationType).to.eq(OperationType.SIGN_IN);
4951
expect(redirectResult.user).to.eql(currentUser);
5052
});
51-
});
53+
});

packages-exp/auth-exp/test/integration/webdriver/util/auth_driver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export enum TestFunction {
3636
AUTH_SNAPSHOT = 'authSnap',
3737
START_AUTH = 'startAuth',
3838
IDP_REDIRECT = 'idpRedirect',
39-
REDIRECT_RESULT = 'redirectResult',
39+
REDIRECT_RESULT = 'redirectResult'
4040
}
4141

4242
/** Helper wraper around the WebDriver object */

packages-exp/auth-exp/test/integration/webdriver/util/idp_page.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
import { By, until, WebDriver } from 'selenium-webdriver';
219
import { JsLoadCondition } from './js_load_condition';
320

@@ -27,7 +44,7 @@ export class IdPPage {
2744
await this.driver.wait(until.elementLocated(SIGN_IN_BUTTON));
2845
const button = await this.driver.findElement(SIGN_IN_BUTTON);
2946
await this.driver.wait(until.elementIsEnabled(button));
30-
await button.click();
47+
await button.click();
3148
}
3249

3350
fillEmail(email: string): Promise<void> {
@@ -52,4 +69,4 @@ export class IdPPage {
5269
await el.click();
5370
await el.sendKeys(text);
5471
}
55-
}
72+
}
Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
1-
import { Condition } from "selenium-webdriver";
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import { Condition } from 'selenium-webdriver';
219

320
/**
421
* A condition that looks for the presence of a specified function. This is
@@ -8,7 +25,9 @@ import { Condition } from "selenium-webdriver";
825
export class JsLoadCondition extends Condition<boolean> {
926
constructor(globalValue: string) {
1027
super(`Waiting for global value ${globalValue}`, driver => {
11-
return driver.executeScript(`return typeof ${globalValue} !== 'undefined';`);
28+
return driver.executeScript(
29+
`return typeof ${globalValue} !== 'undefined';`
30+
);
1231
});
1332
}
14-
}
33+
}

0 commit comments

Comments
 (0)