"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const axios_1 = __importDefault(require("axios"));
const _1 = require(".");
const fs_1 = __importDefault(require("fs"));
const aptosTokens = [
    {
        id: "aptos/coin/aptos_coin_0x1::aptos_coin::aptoscoin",
        ticker: "APT",
        name: "Aptos Coin",
        contract_address: "0x1::aptos_coin::AptosCoin",
        decimals: 8,
        delisted: false,
    },
];
const mockedAxios = jest.spyOn(axios_1.default, "get");
describe("import APT tokens", () => {
    beforeEach(() => {
        mockedAxios.mockImplementation(() => Promise.resolve({
            data: aptosTokens,
            headers: { ["etag"]: "commitHash" },
        }));
    });
    afterEach(() => {
        jest.clearAllMocks();
    });
    it("should output the file in the correct format", async () => {
        const expectedFile = `export type AptosToken = [
  string, // id
  string, // ticker
  string, // name
  string, // contractAddress
  number, // decimals
  boolean?, // delisted
];

import tokens from "./apt_coin.json";

export { default as hash } from "./apt_coin-hash.json";

export default tokens as AptosToken[];
`;
        const mockedFs = (fs_1.default.writeFileSync = jest.fn());
        await (0, _1.importAptosTokens)(".", "coin");
        expect(mockedAxios).toHaveBeenCalledWith("https://crypto-assets-service.api.ledger.com/v1/tokens", {
            params: {
                blockchain_name: "aptos",
                standard: "coin",
                output: "id,ticker,name,contract_address,decimals,delisted",
            },
        });
        expect(mockedFs).toHaveBeenNthCalledWith(1, "apt_coin.json", JSON.stringify([
            [
                "aptos/coin/aptos_coin_0x1::aptos_coin::aptoscoin",
                "APT",
                "Aptos Coin",
                "0x1::aptos_coin::AptosCoin",
                8,
                false,
            ],
        ]));
        expect(mockedFs).toHaveBeenNthCalledWith(2, "apt_coin-hash.json", JSON.stringify("commitHash"));
        expect(mockedFs).toHaveBeenNthCalledWith(3, "apt_coin.ts", expectedFile);
    });
});
//# sourceMappingURL=aptos.test.js.map