maestro-cli-roku
Version:
command line tools for maestro-roku projects
115 lines (114 loc) • 6.89 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var chai_1 = require("chai");
var File_1 = require("./File");
var FileType_1 = require("./FileType");
describe('File File', function () {
describe('Initialization', function () {
it('correctly sets directory', function () {
var file = new File_1.File('/fsPath', '/source', 'test.xml', '.xml');
chai_1.expect(file.filename).to.equal('test.xml');
});
it('correctly sets directory', function () {
var file = new File_1.File('/fsPath', '/source', 'test.xml', '.xml');
chai_1.expect(file.projectPath).to.equal('/source');
});
it('correctly sets extension', function () {
var file = new File_1.File('/fsPath', '/source', 'test.xml', '.xml');
chai_1.expect(file.extension).to.equal('.xml');
});
it('correctly gets fullpath', function () {
var file = new File_1.File('/fsPath', '/source', 'test.xml', '.xml');
chai_1.expect(file.fullPath).to.equal('/fsPath/test.xml');
});
});
describe('getAllParentImportPaths', function () {
it('no parents', function () {
var file = new File_1.File('/fsPath', '/source', 'test.brs', '.brs');
file.importedFiles.push(new File_1.File('/fsPath', '/source', 'import1.brs', '.brs'));
chai_1.expect(file.getAllParentImportPaths()).to.be.empty;
});
it('parent with no import', function () {
var file = new File_1.File('/fsPath', '/source', 'test.brs', '.brs');
var parent = new File_1.File('/fsPath', '/source', 'parent.brs', '.brs');
file.parentFile = parent;
file.importedFiles.push(new File_1.File('/fsPath', '/source', 'import1.brs', '.brs'));
chai_1.expect(file.getAllParentImportPaths()).to.be.empty;
});
it('1 parent with 1 import', function () {
var file = new File_1.File('/fsPath', '/source', 'test.brs', '.brs');
var parent = new File_1.File('/fsPath', '/source', 'parent.brs', '.brs');
file.parentFile = parent;
file.importedFiles.push(new File_1.File('/fsPath', '/source', 'importA.brs', '.brs'));
parent.importedFiles.push(new File_1.File('/fsPath', '/source', 'importB.brs', '.brs'));
//FIXME
// expect(file.getAllParentImportPaths().map( (ns) => ns.name)).to.include.all.members(['B']);
});
it('1 parent with 2 imports', function () {
var file = new File_1.File('/fsPath', '/source', 'test.brs', '.brs');
var parent = new File_1.File('/fsPath', '/source', 'parent.brs', '.brs');
file.parentFile = parent;
file.importedFiles.push(new File_1.File('/fsPath', '/source', 'importA.brs', '.brs'));
parent.importedFiles.push(new File_1.File('/fsPath', '/source', 'importB.brs', '.brs'));
parent.importedFiles.push(new File_1.File('/fsPath', '/source', 'importC.brs', '.brs'));
//FIXME
// expect(file.getAllParentImportPaths().map( (ns) => ns.name)).to.include.all.members(['B', 'C']);
});
it('2 parents with 1 import each', function () {
var file = new File_1.File('/fsPath', '/source', 'test.brs', '.brs');
var parent = new File_1.File('/fsPath', '/source', 'parent.brs', '.brs');
var parent2 = new File_1.File('/fsPath', '/source', 'parent2.brs', '.brs');
parent2.parentFile = parent;
file.parentFile = parent2;
file.importedFiles.push(new File_1.File('/fsPath', '/source', 'importA.brs', '.brs'));
parent.importedFiles.push(new File_1.File('/fsPath', '/source', 'importB.brs', '.brs'));
parent2.importedFiles.push(new File_1.File('/fsPath', '/source', 'importC.brs', '.brs'));
var parentImports = file.getAllParentImportPaths();
//FIXME
// expect(parentImports.map( (ns) => ns.name)).to.include.all.members(['B', 'C']);
});
it('2 parents with 2 imports each', function () {
var file = new File_1.File('/fsPath', '/source', 'test.brs', '.brs');
var parent = new File_1.File('/fsPath', '/source', 'parent.brs', '.brs');
var parent2 = new File_1.File('/fsPath', '/source', 'parent2.brs', '.brs');
parent2.parentFile = parent;
file.parentFile = parent2;
file.importedFiles.push(new File_1.File('/fsPath', '/source', 'importA.brs', '.brs'));
parent.importedFiles.push(new File_1.File('/fsPath', '/source', 'importB.brs', '.brs'));
parent.importedFiles.push(new File_1.File('/fsPath', '/source', 'importD.brs', '.brs'));
parent2.importedFiles.push(new File_1.File('/fsPath', '/source', 'importC.brs', '.brs'));
parent2.importedFiles.push(new File_1.File('/fsPath', '/source', 'importE.brs', '.brs'));
var parentImports = file.getAllParentImportPaths();
//FIXME
// expect(parentImports.map( (ns) => ns.name)).to.include.all.members(['B', 'C', 'D', 'E']);
});
});
describe('file types', function () {
it('correctly identifies type other', function () {
var file = new File_1.File('/fsPath', '/source', 'test.json', '.json');
chai_1.expect(file.fileType).to.equal(FileType_1.FileType.Other);
});
it('correctly identifies type xml', function () {
var file = new File_1.File('/fsPath', '/source', 'test.xml', '.xml');
chai_1.expect(file.fileType).to.equal(FileType_1.FileType.Xml);
});
it('correctly identifies type brs', function () {
var file = new File_1.File('/fsPath', '/source', 'test.brs', '.brs');
chai_1.expect(file.fileType).to.equal(FileType_1.FileType.Brs);
});
it('correctly identifies type viewxml', function () {
var file = new File_1.File('/fsPath', '/source', 'test.xml', '.xml');
file.associatedFile = new File_1.File('/fsPath', '/source', 'test.brs', '.brs');
chai_1.expect(file.fileType).to.equal(FileType_1.FileType.ViewXml);
});
it('correctly identifies type codebehind', function () {
var file = new File_1.File('/fsPath', '/sourcehttps://github.com/georgejecook/brsxmlc', 'test.brs', '.brs');
file.associatedFile = new File_1.File('/fsPath', '/source', 'test.xml', '.xml');
chai_1.expect(file.fileType).to.equal(FileType_1.FileType.CodeBehind);
});
it('correctly identifies type other - no extension', function () {
var file = new File_1.File('/fsPath', '/source', 'test', '');
chai_1.expect(file.fileType).to.equal(FileType_1.FileType.Other);
});
});
});