rename redeemProfileCode to redeemCode, with deprecated alias
[squeep-indieauth-helper] / test / lib / communication.js
index c79d2613f5388485862a3eb83ef7d84304b8582c..a94bf90f6dfed98063916f5500af4430e6d64a34 100644 (file)
@@ -870,7 +870,7 @@ describe('Communication', function () {
     });
   }); // fetchProfile
 
-  describe('redeemProfileCode', function () {
+  describe('redeemCode', function () {
     let expected, urlObj, code, codeVerifier, clientId, redirectURI;
     beforeEach(function () {
       urlObj = new URL('https://example.com/auth');
@@ -887,6 +887,18 @@ describe('Communication', function () {
         me: 'https://profile.example.com/',
       };
 
+      const result = await communication.redeemCode(urlObj, code, codeVerifier, clientId, redirectURI);
+
+      assert.deepStrictEqual(result, expected);
+    });
+    it('covers deprecated method name', async function () {
+      communication.axios.resolves({
+        data: '{"me":"https://profile.example.com/"}',
+      });
+      expected = {
+        me: 'https://profile.example.com/',
+      };
+
       const result = await communication.redeemProfileCode(urlObj, code, codeVerifier, clientId, redirectURI);
 
       assert.deepStrictEqual(result, expected);
@@ -894,11 +906,11 @@ describe('Communication', function () {
     it('covers failure', async function () {
       communication.axios.resolves('Not a JSON payload.');
 
-      const result = await communication.redeemProfileCode(urlObj, code, codeVerifier, clientId, redirectURI);
+      const result = await communication.redeemCode(urlObj, code, codeVerifier, clientId, redirectURI);
 
       assert.strictEqual(result, undefined);
     });
-  }); // redeemProfileCode
+  }); // redeemCode
 
   describe('introspectToken', function () {
     let introspectionUrlObj, authenticationHeader, token;
@@ -958,4 +970,4 @@ describe('Communication', function () {
     });
   }); // deliverTicket
 
-}); // Communication
\ No newline at end of file
+}); // Communication