From ec09a5f033984f971b271080dcf30cc89c815337 Mon Sep 17 00:00:00 2001 From: leonid-regrello Date: Tue, 21 May 2024 16:16:46 -0700 Subject: [PATCH] Add unit test --- test/web-auth/web-auth.test.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/web-auth/web-auth.test.js b/test/web-auth/web-auth.test.js index 69af33a3..4e8da20b 100644 --- a/test/web-auth/web-auth.test.js +++ b/test/web-auth/web-auth.test.js @@ -1897,6 +1897,23 @@ describe('auth0.WebAuth', function () { expect(args.organization).to.eql('org_123'); expect(args.invitation).to.eql('inv_123'); }); + it('should fire the provided callback before redirecting', function () { + let mockCalledTimes = 0; + let mockFn = () => { mockCalledTimes++ }; + + var webAuth = new WebAuth({ + domain: 'me.auth0.com', + redirectUri: 'http://page.com/callback', + clientID: '...', + responseType: 'token', + _sendTelemetry: false + }); + + sinon.spy(webAuth.client, 'buildAuthorizeUrl'); + + webAuth.authorize({}, mockFn); + expect(mockCalledTimes).to.be.equal(1); + }); }); context('renewAuth', function () {