"use strict";
/**
 * Fireblocks API
 * Fireblocks provides a suite of applications to manage digital asset operations and a complete development platform to build your business on the blockchain.  - Visit our website for more information: [Fireblocks Website](https://fireblocks.com) - Visit our developer docs: [Fireblocks DevPortal](https://developers.fireblocks.com)
 *
 * The version of the OpenAPI document: 1.6.2
 * Contact: developers@fireblocks.com
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var bearerTokenProvider_1 = require("../network/bearerTokenProvider");
var jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
jest.mock('jsonwebtoken');
var mockJwtSign = jsonwebtoken_1.default.sign;
describe('BearerTokenProvider Tests', function () {
    var apiKey = 'your-api-key';
    var secretKey = 'your-secret-key';
    var bearerTokenProvider = new bearerTokenProvider_1.BearerTokenProvider(apiKey, secretKey);
    describe('GetToken tests', function () {
        it('Should call jwt.sign with expected parameters for GET when no payload is being used', function () {
            var method = 'GET';
            var path = 'https://example.com/api';
            var expectedToken = 'expected-token-value';
            mockJwtSign.mockReturnValue(expectedToken);
            var token = bearerTokenProvider.getToken(method, path);
            expect(mockJwtSign).toHaveBeenCalledWith({
                uri: '/api',
                nonce: expect.any(String),
                iat: expect.any(Number),
                exp: expect.any(Number),
                sub: apiKey,
                bodyHash: 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
            }, secretKey, { algorithm: 'RS256' });
            expect(token).toBe(expectedToken);
        });
        it('Should return a valid JWT for POST request when payload is used', function () {
            var method = 'POST';
            var path = 'https://example.com/api';
            var payload = JSON.stringify({ key: 'value' });
            var expectedToken = 'expected-token-value';
            mockJwtSign.mockReturnValue(expectedToken);
            var token = bearerTokenProvider.getToken(method, path, payload);
            expect(mockJwtSign).toHaveBeenCalledWith({
                uri: '/api',
                nonce: expect.any(String),
                iat: expect.any(Number),
                exp: expect.any(Number),
                sub: apiKey,
                bodyHash: 'e43abcf3375244839c012f9633f95862d232a95b00d5bc7348b3098b9fed7f32'
            }, secretKey, { algorithm: 'RS256' });
            expect(token).toBe(expectedToken);
        });
    });
});
//# sourceMappingURL=bearerTokenProvider.spec.js.map