Software: Apache. PHP/8.3.27 uname -a: Linux pdx1-shared-a4-04 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64 uid=6659440(dh_z2jmpm) gid=2086089(pg10499364) groups=2086089(pg10499364) Safe-mode: OFF (not secure) /usr/share/nodejs/fast-glob/out/providers/transformers/ drwxr-xr-x | |
| Viewing file: Select action/file-type: "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const path = require("path");
const settings_1 = require("../../settings");
const tests = require("../../tests");
const utils = require("../../utils");
const entry_1 = require("./entry");
function getEntryTransformer(options) {
return new entry_1.default(new settings_1.default(options));
}
function getTransformer(options) {
return getEntryTransformer(options).getTransformer();
}
describe('Providers → Transformers → Entry', () => {
describe('Constructor', () => {
it('should create instance of class', () => {
const filter = getEntryTransformer();
assert.ok(filter instanceof entry_1.default);
});
});
describe('.getTransformer', () => {
it('should return transformed entry as string when options is not provided', () => {
const transformer = getTransformer();
const entry = tests.entry.builder().path('root/file.txt').file().build();
const expected = 'root/file.txt';
const actual = transformer(entry);
assert.strictEqual(actual, expected);
});
it('should return transformed entry as object when the `objectMode` option is enabled', () => {
const transformer = getTransformer({ objectMode: true });
const entry = tests.entry.builder().path('root/file.txt').file().build();
const expected = entry;
const actual = transformer(entry);
assert.deepStrictEqual(actual, expected);
});
it('should return transformed entry as object when the `stats` option is enabled', () => {
const transformer = getTransformer({ stats: true });
const entry = tests.entry.builder().path('root/file.txt').file().stats().build();
const expected = entry;
const actual = transformer(entry);
assert.deepStrictEqual(actual, expected);
});
it('should return entry with absolute filepath when the `absolute` option is enabled', () => {
const transformer = getTransformer({ absolute: true });
const entry = tests.entry.builder().path('root/file.txt').file().build();
const fullpath = path.join(process.cwd(), 'root', 'file.txt');
const expected = utils.path.unixify(fullpath);
const actual = transformer(entry);
assert.strictEqual(actual, expected);
});
it('should return entry with trailing slash when the `markDirectories` is enabled', () => {
const transformer = getTransformer({ markDirectories: true });
const entry = tests.entry.builder().path('root/directory').directory().build();
const expected = 'root/directory/';
const actual = transformer(entry);
assert.strictEqual(actual, expected);
});
it('should return correct entry when the `absolute` and `markDirectories` options is enabled', () => {
const transformer = getTransformer({ absolute: true, markDirectories: true });
const entry = tests.entry.builder().path('root/directory').directory().build();
const fullpath = path.join(process.cwd(), 'root', 'directory', '/');
const expected = utils.path.unixify(fullpath);
const actual = transformer(entry);
assert.strictEqual(actual, expected);
});
it('should do not mutate the entry when the `markDirectories` option is enabled', () => {
const transformer = getTransformer({ markDirectories: true });
const entry = tests.entry.builder().path('root/directory').directory().build();
const actual = transformer(entry);
assert.notStrictEqual(actual, entry.path);
});
});
});
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0127 ]-- |