Skip to content

Commit 8712ee9

Browse files
authored
Lint spec/* files (#468)
1 parent 9753e6a commit 8712ee9

File tree

7 files changed

+51
-47
lines changed

7 files changed

+51
-47
lines changed

spec/apps.spec.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222

2323
import { expect } from 'chai';
2424
import { apps as appsNamespace } from '../src/apps';
25+
2526
import * as firebase from 'firebase-admin';
2627
import * as _ from 'lodash';
2728
import * as sinon from 'sinon';
2829

2930
describe('apps', () => {
3031
let apps: appsNamespace.Apps;
3132
let claims;
33+
3234
beforeEach(() => {
3335
apps = new appsNamespace.Apps();
3436
// mock claims intentionally contains dots, square brackets, and nested paths
@@ -52,37 +54,37 @@ describe('apps', () => {
5254
clock.restore();
5355
});
5456

55-
it('should retain/release ref counters appropriately', function() {
57+
it('should retain/release ref counters appropriately', () => {
5658
apps.retain();
57-
expect(apps['_refCounter']).to.deep.equal({
59+
expect(_.get(apps, '_refCounter')).to.deep.equal({
5860
__admin__: 1,
5961
});
6062
apps.release();
6163
clock.tick(appsNamespace.garbageCollectionInterval);
6264
return Promise.resolve().then(() => {
63-
expect(apps['_refCounter']).to.deep.equal({
65+
expect(_.get(apps, '_refCounter')).to.deep.equal({
6466
__admin__: 0,
6567
});
6668
});
6769
});
6870

69-
it('should only decrement counter after garbageCollectionInterval is up', function() {
71+
it('should only decrement counter after garbageCollectionInterval is up', () => {
7072
apps.retain();
7173
apps.release();
7274
clock.tick(appsNamespace.garbageCollectionInterval / 2);
73-
expect(apps['_refCounter']).to.deep.equal({
75+
expect(_.get(apps, '_refCounter')).to.deep.equal({
7476
__admin__: 1,
7577
});
7678
clock.tick(appsNamespace.garbageCollectionInterval / 2);
7779
return Promise.resolve().then(() => {
78-
expect(apps['_refCounter']).to.deep.equal({
80+
expect(_.get(apps, '_refCounter')).to.deep.equal({
7981
__admin__: 0,
8082
});
8183
});
8284
});
8385

84-
it('should call _destroyApp if app no longer used', function() {
85-
let spy = sinon.spy(apps, '_destroyApp');
86+
it('should call _destroyApp if app no longer used', () => {
87+
const spy = sinon.spy(apps, '_destroyApp');
8688
apps.retain();
8789
apps.release();
8890
clock.tick(appsNamespace.garbageCollectionInterval);
@@ -91,8 +93,8 @@ describe('apps', () => {
9193
});
9294
});
9395

94-
it('should not call _destroyApp if app used again while waiting for release', function() {
95-
let spy = sinon.spy(apps, '_destroyApp');
96+
it('should not call _destroyApp if app used again while waiting for release', () => {
97+
const spy = sinon.spy(apps, '_destroyApp');
9698
apps.retain();
9799
apps.release();
98100
clock.tick(appsNamespace.garbageCollectionInterval / 2);
@@ -103,22 +105,22 @@ describe('apps', () => {
103105
});
104106
});
105107

106-
it('should increment ref counter for each subsequent retain', function() {
108+
it('should increment ref counter for each subsequent retain', () => {
107109
apps.retain();
108-
expect(apps['_refCounter']).to.deep.equal({
110+
expect(_.get(apps, '_refCounter')).to.deep.equal({
109111
__admin__: 1,
110112
});
111113
apps.retain();
112-
expect(apps['_refCounter']).to.deep.equal({
114+
expect(_.get(apps, '_refCounter')).to.deep.equal({
113115
__admin__: 2,
114116
});
115117
apps.retain();
116-
expect(apps['_refCounter']).to.deep.equal({
118+
expect(_.get(apps, '_refCounter')).to.deep.equal({
117119
__admin__: 3,
118120
});
119121
});
120122

121-
it('should work with staggering sets of retain/release', function() {
123+
it('should work with staggering sets of retain/release', () => {
122124
apps.retain();
123125
apps.release();
124126
clock.tick(appsNamespace.garbageCollectionInterval / 2);
@@ -128,14 +130,14 @@ describe('apps', () => {
128130
return Promise.resolve()
129131
.then(() => {
130132
// Counters are still 1 due second set of retain/release
131-
expect(apps['_refCounter']).to.deep.equal({
133+
expect(_.get(apps, '_refCounter')).to.deep.equal({
132134
__admin__: 1,
133135
});
134136
clock.tick(appsNamespace.garbageCollectionInterval / 2);
135137
})
136138
.then(() => {
137139
// It's now been a full interval since the second set of retain/release
138-
expect(apps['_refCounter']).to.deep.equal({
140+
expect(_.get(apps, '_refCounter')).to.deep.equal({
139141
__admin__: 0,
140142
});
141143
});

spec/cloud-functions.spec.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
// SOFTWARE.
2222

23-
import * as _ from 'lodash';
2423
import { expect } from 'chai';
24+
import * as _ from 'lodash';
25+
2526
import {
27+
Change,
2628
Event,
2729
EventContext,
2830
makeCloudFunction,
2931
MakeCloudFunctionArgs,
30-
Change,
3132
} from '../src/cloud-functions';
3233

3334
describe('makeCloudFunction', () => {
@@ -41,7 +42,7 @@ describe('makeCloudFunction', () => {
4142
};
4243

4344
it('should put a __trigger on the returned CloudFunction', () => {
44-
let cf = makeCloudFunction({
45+
const cf = makeCloudFunction({
4546
provider: 'mock.provider',
4647
eventType: 'mock.event',
4748
service: 'service',
@@ -58,7 +59,7 @@ describe('makeCloudFunction', () => {
5859
});
5960

6061
it('should have legacy event type in __trigger if provided', () => {
61-
let cf = makeCloudFunction(cloudFunctionArgs);
62+
const cf = makeCloudFunction(cloudFunctionArgs);
6263
expect(cf.__trigger).to.deep.equal({
6364
eventTrigger: {
6465
eventType: 'providers/provider/eventTypes/event',
@@ -69,11 +70,11 @@ describe('makeCloudFunction', () => {
6970
});
7071

7172
it('should construct the right context for event', () => {
72-
let args: any = _.assign({}, cloudFunctionArgs, {
73+
const args: any = _.assign({}, cloudFunctionArgs, {
7374
handler: (data: any, context: EventContext) => context,
7475
});
75-
let cf = makeCloudFunction(args);
76-
let test: Event = {
76+
const cf = makeCloudFunction(args);
77+
const test: Event = {
7778
context: {
7879
eventId: '00000',
7980
timestamp: '2016-11-04T21:29:03.496Z',
@@ -99,12 +100,12 @@ describe('makeCloudFunction', () => {
99100
});
100101

101102
it('should throw error when context.params accessed in handler environment', () => {
102-
let args: any = _.assign({}, cloudFunctionArgs, {
103+
const args: any = _.assign({}, cloudFunctionArgs, {
103104
handler: (data: any, context: EventContext) => context,
104105
triggerResource: () => null,
105106
});
106-
let cf = makeCloudFunction(args);
107-
let test: Event = {
107+
const cf = makeCloudFunction(args);
108+
const test: Event = {
108109
context: {
109110
eventId: '00000',
110111
timestamp: '2016-11-04T21:29:03.496Z',
@@ -179,7 +180,7 @@ describe('makeAuth and makeAuthType', () => {
179180
};
180181
},
181182
};
182-
let cf = makeCloudFunction(args);
183+
const cf = makeCloudFunction(args);
183184

184185
it('should construct correct auth and authType for admin user', () => {
185186
const testEvent = {
@@ -311,7 +312,7 @@ describe('Change', () => {
311312

312313
describe('fromJSON', () => {
313314
it('should create a Change object with a `before` and `after`', () => {
314-
let created = Change.fromJSON<any>({
315+
const created = Change.fromJSON<any>({
315316
before: { foo: 'bar' },
316317
after: { foo: 'faz' },
317318
});
@@ -325,7 +326,7 @@ describe('Change', () => {
325326
_.set(input, 'another', 'value');
326327
return input as T;
327328
}
328-
let created = Change.fromJSON<Object>(
329+
const created = Change.fromJSON<object>(
329330
{
330331
before: { foo: 'bar' },
331332
after: { foo: 'faz' },

spec/config.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
// SOFTWARE.
2222

23-
import * as mockRequire from 'mock-require';
2423
import { expect } from 'chai';
24+
import * as mockRequire from 'mock-require';
2525
import { config, firebaseConfig } from '../src/config';
2626

2727
describe('config()', () => {
@@ -34,7 +34,7 @@ describe('config()', () => {
3434

3535
it('loads config values from .runtimeconfig.json', () => {
3636
mockRequire('../../../.runtimeconfig.json', { foo: 'bar', firebase: {} });
37-
let loaded = config();
37+
const loaded = config();
3838
expect(loaded).to.not.have.property('firebase');
3939
expect(loaded).to.have.property('foo', 'bar');
4040
});

spec/function-builder.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('FunctionBuilder', () => {
3434
});
3535

3636
it('should allow supported region to be set', () => {
37-
let fn = functions
37+
const fn = functions
3838
.region('us-east1')
3939
.auth.user()
4040
.onCreate(user => user);
@@ -43,7 +43,7 @@ describe('FunctionBuilder', () => {
4343
});
4444

4545
it('should allow multiple supported regions to be set', () => {
46-
let fn = functions
46+
const fn = functions
4747
.region('us-east1', 'us-central1')
4848
.auth.user()
4949
.onCreate(user => user);
@@ -52,7 +52,7 @@ describe('FunctionBuilder', () => {
5252
});
5353

5454
it('should allow all supported regions to be set', () => {
55-
let fn = functions
55+
const fn = functions
5656
.region(
5757
'us-central1',
5858
'us-east1',
@@ -75,7 +75,7 @@ describe('FunctionBuilder', () => {
7575
});
7676

7777
it('should allow valid runtime options to be set', () => {
78-
let fn = functions
78+
const fn = functions
7979
.runWith({
8080
timeoutSeconds: 90,
8181
memory: '256MB',
@@ -88,7 +88,7 @@ describe('FunctionBuilder', () => {
8888
});
8989

9090
it('should allow both supported region and valid runtime options to be set', () => {
91-
let fn = functions
91+
const fn = functions
9292
.region('europe-west2')
9393
.runWith({
9494
timeoutSeconds: 90,
@@ -103,7 +103,7 @@ describe('FunctionBuilder', () => {
103103
});
104104

105105
it('should allow both valid runtime options and supported region to be set in reverse order', () => {
106-
let fn = functions
106+
const fn = functions
107107
.runWith({
108108
timeoutSeconds: 90,
109109
memory: '256MB',

spec/index.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,20 @@ import * as nock from 'nock';
2828
nock.disableNetConnect();
2929

3030
import 'mocha';
31-
import './utils.spec';
31+
3232
import './apps.spec';
3333
import './cloud-functions.spec';
3434
import './config.spec';
35-
import './setup.spec';
36-
import './testing.spec';
3735
import './function-builder.spec';
3836
import './providers/analytics.spec';
3937
import './providers/auth.spec';
38+
import './providers/crashlytics.spec';
4039
import './providers/database.spec';
4140
import './providers/firestore.spec';
4241
import './providers/https.spec';
4342
import './providers/pubsub.spec';
4443
import './providers/remoteConfig.spec';
4544
import './providers/storage.spec';
46-
import './providers/crashlytics.spec';
45+
import './setup.spec';
46+
import './testing.spec';
47+
import './utils.spec';

spec/testing.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import * as testing from '../src/testing';
2626

2727
// TODO(rjh): As actual testing methods become available, replace this with actual tests.
2828
describe('testing', () => {
29-
it('should be accessible through the entrypoint', function() {
29+
it('should be accessible through the entrypoint', () => {
3030
expect(testing.whereAreTheBugs()).to.not.equal('Earth');
3131
});
3232
});

spec/utils.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
// SOFTWARE.
2222

23-
import { normalizePath, pathParts, valAt, applyChange } from '../src/utils';
2423
import { expect } from 'chai';
24+
import { applyChange, normalizePath, pathParts, valAt } from '../src/utils';
2525

2626
describe('utils', () => {
2727
describe('.normalizePath(path: string)', () => {
@@ -71,9 +71,9 @@ describe('utils', () => {
7171
});
7272

7373
it('should return the merged value of two objects', () => {
74-
let from = { a: { b: 'foo', c: 23, d: 444 }, d: { e: 42 } };
75-
let to: any = { a: { b: 'bar', c: null }, d: null, e: { f: 'g' } };
76-
let result = { a: { b: 'bar', d: 444 }, e: { f: 'g' } };
74+
const from = { a: { b: 'foo', c: 23, d: 444 }, d: { e: 42 } };
75+
const to: any = { a: { b: 'bar', c: null }, d: null, e: { f: 'g' } };
76+
const result = { a: { b: 'bar', d: 444 }, e: { f: 'g' } };
7777
expect(applyChange(from, to)).to.deep.equal(result);
7878
});
7979
});

0 commit comments

Comments
 (0)