"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const path = require("path");
const npm_1 = require("../src/server/npm");
describe('npm', () => {
    it('findPackageJson', () => {
        chai_1.expect(npm_1.findPackageJson(__dirname)).to.equal(path.join(__dirname, '..', 'package.json'));
        chai_1.expect(npm_1.findPackageJson('/')).to.be.undefined;
    });
    it('mustLoadPackageJson', () => {
        chai_1.expect(npm_1.mustLoadPackageJson(__dirname)).to.containSubset({ name: '@mcph/miix-cli' });
        chai_1.expect(() => npm_1.mustLoadPackageJson('/')).to.throw(/Could not find a package/);
    });
    it('getProjectPath', () => {
        chai_1.expect(npm_1.getProjectPath(__dirname)).to.equal(path.join(__dirname, '..'));
        chai_1.expect(npm_1.getProjectPath('/')).to.be.undefined;
    });
    it('getDependencyPath', () => {
        chai_1.expect(npm_1.getDependencyPath('mocha')).to.equal(path.join(__dirname, '../node_modules/mocha'));
    });
    it('getPackageExecutable', () => __awaiter(this, void 0, void 0, function* () {
        chai_1.expect(npm_1.getPackageExecutable(npm_1.getDependencyPath('mocha'))).to.equal(path.join(__dirname, '../node_modules/mocha/bin/mocha'));
    }));
    it('findReadme', () => __awaiter(this, void 0, void 0, function* () {
        chai_1.expect(yield npm_1.findReadme(path.join(__dirname, '..'))).to.equal('readme.md');
        chai_1.expect(yield npm_1.findReadme(path.join(__dirname, 'fixture/custom-readme'))).to.equal('manual.md');
    }));
});
