Skip to content

Commit e8bfa1b

Browse files
committed
test: Add test for updating enabled clients with more than 50 clients
1 parent a1ef78a commit e8bfa1b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/tools/auth0/handlers/connections.tests.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,36 @@ describe('#connections enabled clients functionality', () => {
742742
]
743743
);
744744
});
745+
746+
it('should update enabled clients with more than 50 clients', async () => {
747+
const connectionId = 'con_123';
748+
const enabledClientIds = Array.from({ length: 60 }, (_, i) => `client_${i + 1}`);
749+
const typeName = 'connection';
750+
751+
mockAuth0Client.connections.updateEnabledClients.resolves();
752+
753+
const result = await updateConnectionEnabledClients(
754+
mockAuth0Client,
755+
typeName,
756+
connectionId,
757+
enabledClientIds
758+
);
759+
760+
expect(result).to.equal(true);
761+
sinon.assert.calledTwice(mockAuth0Client.connections.updateEnabledClients);
762+
763+
const firstCall = mockAuth0Client.connections.updateEnabledClients.getCall(0);
764+
expect(firstCall.args[0]).to.deep.equal({ id: connectionId });
765+
expect(firstCall.args[1]).to.have.length(50);
766+
expect(firstCall.args[1][0]).to.deep.equal({ client_id: 'client_1', status: true });
767+
expect(firstCall.args[1][49]).to.deep.equal({ client_id: 'client_50', status: true });
768+
769+
const secondCall = mockAuth0Client.connections.updateEnabledClients.getCall(1);
770+
expect(secondCall.args[0]).to.deep.equal({ id: connectionId });
771+
expect(secondCall.args[1]).to.have.length(10);
772+
expect(secondCall.args[1][0]).to.deep.equal({ client_id: 'client_51', status: true });
773+
expect(secondCall.args[1][9]).to.deep.equal({ client_id: 'client_60', status: true });
774+
});
745775
});
746776

747777
describe('#processConnectionEnabledClients', () => {

0 commit comments

Comments
 (0)