burp-brightscript
Version:
lightweight processor for roku brightscript projects
57 lines • 2.95 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var chai_1 = require("chai");
var FileDescriptor_1 = require("./FileDescriptor");
var FileType_1 = require("./FileType");
describe('File Descriptor', function () {
describe('Initialization', function () {
it('correctly sets directory', function () {
var file = new FileDescriptor_1.default('/source', 'test.xml', '.xml');
chai_1.expect(file.filename).to.equal('test.xml');
});
it('correctly sets directory', function () {
var file = new FileDescriptor_1.default('/source', 'test.xml', '.xml');
chai_1.expect(file.directory).to.equal('/source');
});
it('correctly sets extension', function () {
var file = new FileDescriptor_1.default('/source', 'test.xml', '.xml');
chai_1.expect(file.extension).to.equal('.xml');
});
it('correctly gets fullpath', function () {
var file = new FileDescriptor_1.default('/source', 'test.xml', '.xml');
chai_1.expect(file.fullPath).to.equal('/source/test.xml');
});
});
describe('file types', function () {
it('correctly identifies type other', function () {
var file = new FileDescriptor_1.default('/source', 'test.json', '.json');
chai_1.expect(file.fileType).to.equal(FileType_1.FileType.Other);
});
it('correctly identifies type xml', function () {
var file = new FileDescriptor_1.default('/source', 'test.xml', '.xml');
chai_1.expect(file.fileType).to.equal(FileType_1.FileType.Other);
});
it('correctly identifies type brs', function () {
var file = new FileDescriptor_1.default('/source', 'test.brs', '.brs');
chai_1.expect(file.fileType).to.equal(FileType_1.FileType.Brs);
});
it('correctly identifies type other - no extension', function () {
var file = new FileDescriptor_1.default('/source', 'test', '');
chai_1.expect(file.fileType).to.equal(FileType_1.FileType.Other);
});
});
describe('getPackagePath', function () {
it("get's correct package paths", function () {
var testParams = [
{ path: 'build/source', rootPath: 'build', expected: 'pkg:/source/test.brs' },
{ path: '/build/source', rootPath: 'build', expected: 'pkg:/source/test.brs' },
{ path: '/project/build/development/source', rootPath: 'project/build/development', expected: 'pkg:/source/test.brs' }
];
testParams.forEach(function (param) {
var file = new FileDescriptor_1.default(param.path, 'test.brs', '.brs');
chai_1.expect(file.getPackagePath(param.rootPath, process.cwd())).to.equal('pkg:/source/test.brs');
});
});
});
});
//# sourceMappingURL=FileDescriptor.spec.js.map