Skip to content

Commit a84c639

Browse files
committed
remove foreach checks
1 parent 94d9147 commit a84c639

File tree

1 file changed

+20
-60
lines changed

1 file changed

+20
-60
lines changed

test/integration/data-connect.spec.ts

Lines changed: 20 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,7 @@ describe('getDataConnect()', () => {
318318
it('executeGraphql() successfully executes a GraphQL query', async () => {
319319
const resp = await getDataConnect(connectorConfig)
320320
.executeGraphql<ListUsersResponse, unknown>(queryListUsers);
321-
resp.data.users.forEach((user) => {
322-
expect(initialState.users).to.deep.include(user);
323-
});
321+
expect(resp.data.users).to.deep.equal(initialState.users);
324322
});
325323

326324
it('executeGraphql() use the operationName when multiple queries are provided', async () => {
@@ -349,9 +347,7 @@ describe('getDataConnect()', () => {
349347
it('executeGraphqlRead() successfully executes a read-only GraphQL', async () => {
350348
const resp = await getDataConnect(connectorConfig)
351349
.executeGraphqlRead<ListUsersResponse, unknown>(queryListUsers);
352-
resp.data.users.forEach((user) => {
353-
expect(initialState.users).to.deep.include(user);
354-
});
350+
expect(resp.data.users).to.deep.equal(initialState.users);
355351
});
356352

357353
it('executeGraphqlRead() should throw for a GraphQL mutation', async () => {
@@ -428,26 +424,20 @@ describe('getDataConnect()', () => {
428424
it('executeGraphql() successfully executes an impersonated query with authenticated claims', async () => {
429425
const resp = await getDataConnect(connectorConfig).executeGraphql<ListUsersResponse, unknown>(
430426
queryListUsers, optsAuthorizedFredClaims);
431-
resp.data.users.forEach((user) => {
432-
expect(initialState.users).to.deep.include(user);
433-
});
427+
expect(resp.data.users).to.deep.equal(initialState.users);
434428
});
435429

436430
it('executeGraphql() successfully executes an impersonated query with unauthenticated claims', async () => {
437431
const resp = await getDataConnect(connectorConfig).executeGraphql<ListUsersResponse, unknown>(
438432
queryListUsers, optsUnauthorizedClaims);
439-
resp.data.users.forEach((user) => {
440-
expect(initialState.users).to.deep.include(user);
441-
});
433+
expect(resp.data.users).to.deep.equal(initialState.users);
442434
});
443435

444436
it('executeGraphql() successfully executes an impersonated query with non-existing authenticated claims',
445437
async () => {
446438
const resp = await getDataConnect(connectorConfig).executeGraphql<ListUsersResponse, unknown>(
447439
queryListUsers, optsNonExistingClaims);
448-
resp.data.users.forEach((user) => {
449-
expect(initialState.users).to.deep.include(user);
450-
});
440+
expect(resp.data.users).to.deep.equal(initialState.users);
451441
});
452442
});
453443

@@ -496,9 +486,7 @@ describe('getDataConnect()', () => {
496486
undefined,
497487
optsUnauthorizedClaims
498488
);
499-
resp.data.users.forEach((user) => {
500-
expect(initialState.users).to.deep.include(user);
501-
});
489+
expect(resp.data.users).to.deep.equal(initialState.users);
502490
});
503491

504492
it('should fail to execute a query with @auth(level: USER_ANON)', () => {
@@ -531,18 +519,14 @@ describe('getDataConnect()', () => {
531519
const resp = await getDataConnect(connectorConfig).executeQuery<ListUsersResponse, undefined>(
532520
'ListUsersPublic', undefined, optsAuthorizedFredAnonClaims
533521
);
534-
resp.data.users.forEach((user) => {
535-
expect(initialState.users).to.deep.include(user);
536-
});
522+
expect(resp.data.users).to.deep.equal(initialState.users);
537523
});
538524

539525
it('should successfully execute a query with @auth(level: USER_ANON)', async () => {
540526
const resp = await getDataConnect(connectorConfig).executeQuery<ListUsersResponse, undefined>(
541527
'ListUsersUserAnon', undefined, optsAuthorizedFredAnonClaims
542528
);
543-
resp.data.users.forEach((user) => {
544-
expect(initialState.users).to.deep.include(user);
545-
});
529+
expect(resp.data.users).to.deep.equal(initialState.users);
546530
});
547531

548532
it('should fail to execute a query with @auth(level: USER)', async () => {
@@ -577,27 +561,21 @@ describe('getDataConnect()', () => {
577561
const resp = await getDataConnect(connectorConfig).executeQuery<ListUsersResponse, undefined>(
578562
'ListUsersPublic', undefined, optsAuthorizedFredClaims
579563
);
580-
resp.data.users.forEach((user) => {
581-
expect(initialState.users).to.deep.include(user);
582-
});
564+
expect(resp.data.users).to.deep.equal(initialState.users);
583565
});
584566

585567
it('should successfully execute a query with @auth(level: USER_ANON)', async () => {
586568
const resp = await getDataConnect(connectorConfig).executeQuery<ListUsersResponse, undefined>(
587569
'ListUsersUserAnon', undefined, optsAuthorizedFredClaims
588570
);
589-
resp.data.users.forEach((user) => {
590-
expect(initialState.users).to.deep.include(user);
591-
});
571+
expect(resp.data.users).to.deep.equal(initialState.users);
592572
});
593573

594574
it('should successfully execute a query with @auth(level: USER)', async () => {
595575
const resp = await getDataConnect(connectorConfig).executeQuery<ListUsersResponse, undefined>(
596576
'ListUsersUser', undefined, optsAuthorizedFredClaims
597577
);
598-
resp.data.users.forEach((user) => {
599-
expect(initialState.users).to.deep.include(user);
600-
});
578+
expect(resp.data.users).to.deep.equal(initialState.users);
601579
});
602580

603581
it('should fail to execute a query with @auth(level: USER_EMAIL_VERIFIED)', async () => {
@@ -626,36 +604,28 @@ describe('getDataConnect()', () => {
626604
const resp = await getDataConnect(connectorConfig).executeQuery<ListUsersResponse, undefined>(
627605
'ListUsersPublic', undefined, optsAuthorizedFredEmailVerifiedClaims
628606
);
629-
resp.data.users.forEach((user) => {
630-
expect(initialState.users).to.deep.include(user);
631-
});
607+
expect(resp.data.users).to.deep.equal(initialState.users);
632608
});
633609

634610
it('should successfully execute a query with @auth(level: USER_ANON)', async () => {
635611
const resp = await getDataConnect(connectorConfig).executeQuery<ListUsersResponse, undefined>(
636612
'ListUsersUserAnon', undefined, optsAuthorizedFredEmailVerifiedClaims
637613
);
638-
resp.data.users.forEach((user) => {
639-
expect(initialState.users).to.deep.include(user);
640-
});
614+
expect(resp.data.users).to.deep.equal(initialState.users);
641615
});
642616

643617
it('should successfully execute a query with @auth(level: USER)', async () => {
644618
const resp = await getDataConnect(connectorConfig).executeQuery<ListUsersResponse, undefined>(
645619
'ListUsersUser', undefined, optsAuthorizedFredEmailVerifiedClaims
646620
);
647-
resp.data.users.forEach((user) => {
648-
expect(initialState.users).to.deep.include(user);
649-
});
621+
expect(resp.data.users).to.deep.equal(initialState.users);
650622
});
651623

652624
it('should successfully execute a query with @auth(level: USER_EMAIL_VERIFIED)', async () => {
653625
const resp = await getDataConnect(connectorConfig).executeQuery<ListUsersResponse, undefined>(
654626
'ListUsersUserEmailVerified', undefined, optsAuthorizedFredEmailVerifiedClaims
655627
);
656-
resp.data.users.forEach((user) => {
657-
expect(initialState.users).to.deep.include(user);
658-
});
628+
expect(resp.data.users).to.deep.equal(initialState.users);
659629
});
660630

661631
it('should fail to execute a query with @auth(level: NO_ACCESS)', async () => {
@@ -678,45 +648,35 @@ describe('getDataConnect()', () => {
678648
const resp = await getDataConnect(connectorConfig).executeQuery<ListUsersResponse>(
679649
'ListUsersPublic'
680650
);
681-
resp.data.users.forEach((user) => {
682-
expect(initialState.users).to.deep.include(user);
683-
});
651+
expect(resp.data.users).to.deep.equal(initialState.users);
684652
});
685653

686654
it('should successfully execute a query with @auth(level: USER_ANON)', async () => {
687655
const resp = await getDataConnect(connectorConfig).executeQuery<ListUsersResponse>(
688656
'ListUsersUserAnon'
689657
);
690-
resp.data.users.forEach((user) => {
691-
expect(initialState.users).to.deep.include(user);
692-
});
658+
expect(resp.data.users).to.deep.equal(initialState.users);
693659
});
694660

695661
it('should successfully execute a query with @auth(level: USER)', async () => {
696662
const resp = await getDataConnect(connectorConfig).executeQuery<ListUsersResponse>(
697663
'ListUsersUser'
698664
);
699-
resp.data.users.forEach((user) => {
700-
expect(initialState.users).to.deep.include(user);
701-
});
665+
expect(resp.data.users).to.deep.equal(initialState.users);
702666
});
703667

704668
it('should successfully execute a query with @auth(level: USER_EMAIL_VERIFIED)', async () => {
705669
const resp = await getDataConnect(connectorConfig).executeQuery<ListUsersResponse>(
706670
'ListUsersUserEmailVerified'
707671
);
708-
resp.data.users.forEach((user) => {
709-
expect(initialState.users).to.deep.include(user);
710-
});
672+
expect(resp.data.users).to.deep.equal(initialState.users);
711673
});
712674

713675
it('should successfully execute a query with @auth(level: NO_ACCESS)', async () => {
714676
const resp = await getDataConnect(connectorConfig).executeQuery<ListUsersResponse>(
715677
'ListUsersNoAccess'
716678
);
717-
resp.data.users.forEach((user) => {
718-
expect(initialState.users).to.deep.include(user);
719-
});
679+
expect(resp.data.users).to.deep.equal(initialState.users);
720680
});
721681

722682
it("should fail to execute a query using the impersonated user's auth.uid", async () => {

0 commit comments

Comments
 (0)