"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
const os = __importStar(require("os"));
const repo_1 = __importDefault(require("../lib/repo"));
const fs_extra_1 = require("fs-extra");
describe('add assets', () => {
    let projectDir;
    beforeEach(() => {
        projectDir = `${os.tmpdir()}/fun-project`;
        console.log(projectDir);
        fs_extra_1.removeSync(projectDir);
        fs_extra_1.ensureDirSync(projectDir);
    });
    test('add nest model', async () => {
        const repo = new repo_1.default(projectDir);
        repo.init();
        await repo.add({ name: 'jesse2/test/green-cube', version: '1.0.0' });
        const packages = JSON.parse(fs.readFileSync(`${projectDir}/modelnest.json`, 'utf8'));
        expect(packages.assets).toEqual({
            "jesse2/test/green-cube": "1.0.0"
        });
        expect(packages.nest).toBe('nest_models');
        const exists = fs.existsSync(`${projectDir}/nest_models`);
        expect(exists).toBeTruthy();
        const assetFiles = fs.readdirSync(`${repo.modelNestDirectory}/jesse2/test/green-cube`);
        expect(assetFiles).toContain('version.json');
        expect(assetFiles.sort()).toEqual([
            'version.json',
            'green_cube.mtl',
            'green_cube.obj',
            'torso_ZBrushTexture.001.jpg',
        ].sort());
    });
    test('update nest model', async () => {
        const repo = new repo_1.default(projectDir);
        repo.init();
        await repo.add({ name: 'jesse2/test/green-cube', version: '1.0.0' });
        const newVersions = await repo.update('jesse2/test/green-cube');
        const packages = JSON.parse(fs.readFileSync(`${projectDir}/modelnest.json`, 'utf8'));
        expect(packages.assets).toEqual({
            "jesse2/test/green-cube": "2.0.0"
        });
        expect(packages.nest).toBe('nest_models');
        const exists = fs.existsSync(`${projectDir}/nest_models`);
        expect(exists).toBeTruthy();
        const assetFiles = fs.readdirSync(`${repo.modelNestDirectory}/jesse2/test/green-cube`);
        expect(assetFiles).toContain('version.json');
        expect(assetFiles.sort()).toEqual([
            'version.json',
            'green_cube.mtl',
            'green_cube.obj',
            'torso_ZBrushTexture.001.jpg',
            'torso_ZBrushTexture.001 copy.jpg',
        ].sort());
    });
});
//# sourceMappingURL=manage-assets.test.js.map