"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 vip180Tokens = [
    {
        id: "vechain/vip180/vtho",
        blockchain_name: "vechain",
        contract_address: "0x0000000000000000000000000000456E65726779",
        decimals: 18,
        network_type: "main",
        delisted: false,
        name: "Vethor",
        ticker: "VTHO",
    },
];
const mockedAxios = jest.spyOn(axios_1.default, "get");
describe("import Vip180 tokens", () => {
    beforeEach(() => {
        mockedAxios.mockImplementation(() => Promise.resolve({
            data: vip180Tokens,
            headers: { ["etag"]: "commitHash" },
        }));
    });
    afterEach(() => {
        jest.clearAllMocks();
    });
    it("should output the file in the correct format", async () => {
        const expectedFile = `export type Vip180Token = [
  string, // token identifier
  string, // ticker
  string, // name
  string, // contract address
  number, // decimals
];

import tokens from "./vip180.json";

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

export default tokens as Vip180Token[];
`;
        const mockedFs = (fs_1.default.writeFileSync = jest.fn());
        await (0, _1.importVip180Tokens)(".");
        expect(mockedAxios).toHaveBeenCalledWith("https://crypto-assets-service.api.ledger.com/v1/tokens", {
            params: {
                blockchain_name: "vechain",
                chain_id: undefined,
                output: "id,ticker,name,contract_address,decimals",
                standard: undefined,
            },
        });
        expect(mockedFs).toHaveBeenNthCalledWith(1, "vip180.json", JSON.stringify([
            ["vtho", "VTHO", "Vethor", "0x0000000000000000000000000000456E65726779", 18],
        ]));
        expect(mockedFs).toHaveBeenNthCalledWith(2, "vip180-hash.json", JSON.stringify("commitHash"));
        expect(mockedFs).toHaveBeenNthCalledWith(3, "vip180.ts", expectedFile);
    });
});
//# sourceMappingURL=vip180.test.js.map