Uname: Linux webm016.cluster127.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 7.4.33 [ PHP INFO ] PHP os: Linux
Server Ip: 54.36.31.145
Your Ip: 216.73.216.182
User: homesquasz (91404) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : index.spec.ts
import * as assert from 'assert';
import * as fs from 'fs';
import { Readable } from 'stream';

import * as rimraf from 'rimraf';

import { Errno } from './types';
import { walk, walkSync, walkStream, Settings, Entry } from '.';

const entryFilter = (entry: Entry): boolean => !entry.dirent.isDirectory();

function streamToPromise(stream: Readable): Promise<Entry[]> {
	const entries: Entry[] = [];

	return new Promise((resolve, reject) => {
		stream.on('data', (entry: Entry) => entries.push(entry));
		stream.once('error', reject);
		stream.once('end', () => resolve(entries));
	});
}

describe('Package', () => {
	before(() => {
		rimraf.sync('fixtures');

		fs.mkdirSync('fixtures');
		fs.writeFileSync('fixtures/file.txt', '');
		fs.mkdirSync('fixtures/nested');
		fs.writeFileSync('fixtures/nested/file.txt', '');
	});

	after(() => {
		rimraf.sync('fixtures');
	});

	describe('.walk', () => {
		it('should throw an error for non-exist directory', (done) => {
			walk('non-exist-directory', (error, entries) => {
				assert.strictEqual(error.code, 'ENOENT');
				assert.strictEqual(entries, undefined);
				done();
			});
		});

		it('should work without options or settings', (done) => {
			walk('fixtures', (error, entries) => {
				assert.strictEqual(error, null);
				assert.strictEqual(entries.length, 3);
				done();
			});
		});

		it('should work with options', (done) => {
			walk('fixtures', { entryFilter }, (error, entries) => {
				assert.strictEqual(error, null);
				assert.strictEqual(entries.length, 2);
				done();
			});
		});

		it('should work with settings', (done) => {
			const settings = new Settings({ entryFilter });

			walk('fixtures', settings, (error, entries) => {
				assert.strictEqual(error, null);
				assert.strictEqual(entries.length, 2);
				done();
			});
		});
	});

	describe('.walkStream', () => {
		it('should throw an error for non-exist directory', async () => {
			const stream = walkStream('non-exist-directory');

			await assert.rejects(() => streamToPromise(stream), (error: Errno) => error.code === 'ENOENT');
		});

		it('should work without options or settings', async () => {
			const stream = walkStream('fixtures');
			const actual = await streamToPromise(stream);

			assert.strictEqual(actual.length, 3);
		});

		it('should work with options', async () => {
			const stream = walkStream('fixtures', { entryFilter });
			const actual = await streamToPromise(stream);

			assert.strictEqual(actual.length, 2);
		});

		it('should work with settings', async () => {
			const settings = new Settings({ entryFilter });
			const stream = walkStream('fixtures', settings);
			const actual = await streamToPromise(stream);

			assert.strictEqual(actual.length, 2);
		});
	});

	describe('.walkSync', () => {
		it('should throw an error for non-exist directory', () => {
			const matcher = (error: Errno): boolean => error.code === 'ENOENT';

			assert.throws(() => walkSync('non-exist-directory'), matcher);
		});

		it('should work without options or settings', () => {
			const actual = walkSync('fixtures');

			assert.strictEqual(actual.length, 3);
		});

		it('should work with options', () => {
			const actual = walkSync('fixtures', { entryFilter });

			assert.strictEqual(actual.length, 2);
		});

		it('should work with settings', () => {
			const settings = new Settings({ entryFilter });

			const actual = walkSync('fixtures', settings);

			assert.strictEqual(actual.length, 2);
		});
	});
});
© 2026 GrazzMean
Page non trouvée – APK Comptoir Hammami
Jannah Theme License is not validated, Go to the theme options page to validate the license, You need a single license for each domain name.

404 :(

Oups ! Cette page est introuvable.

Il semble que nous ne puissions pas trouver ce que vous cherchez. Peut-être qu'une recherche pourrait vous aider.

Bouton retour en haut de la page