Son CV dans un terminal web en Javascript! https://terminal-cv.gregandev.fr
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
terminal-cv/node_modules/@parcel/core/test/InternalAsset.test.js

78 lines
2.2 KiB

// @flow strict-local
import assert from 'assert';
import UncommittedAsset from '../src/UncommittedAsset';
import {createAsset as _createAsset} from '../src/assetUtils';
import {createEnvironment} from '../src/Environment';
import {DEFAULT_OPTIONS} from './test-utils';
import {toProjectPath} from '../src/projectPath';
function createAsset(opts) {
return _createAsset('/', opts);
}
const stats = {time: 0, size: 0};
describe('InternalAsset', () => {
it('only includes connected files once per filePath', () => {
let asset = new UncommittedAsset({
value: createAsset({
filePath: toProjectPath('/', '/foo/asset.js'),
env: createEnvironment(),
stats,
type: 'js',
isSource: true,
}),
options: DEFAULT_OPTIONS,
});
asset.invalidateOnFileChange(toProjectPath('/', '/foo/file'));
asset.invalidateOnFileChange(toProjectPath('/', '/foo/file'));
assert.deepEqual(asset.getInvalidations(), [
{
type: 'file',
filePath: 'foo/file',
},
]);
});
it('only includes dependencies once per id', () => {
let asset = new UncommittedAsset({
value: createAsset({
filePath: toProjectPath('/', '/foo/asset.js'),
env: createEnvironment(),
stats,
type: 'js',
isSource: true,
}),
options: DEFAULT_OPTIONS,
});
asset.addDependency({specifier: './foo', specifierType: 'esm'});
asset.addDependency({specifier: './foo', specifierType: 'esm'});
let dependencies = asset.getDependencies();
assert(dependencies.length === 1);
assert(dependencies[0].specifier === './foo');
});
it('includes different dependencies if their id differs', () => {
let asset = new UncommittedAsset({
value: createAsset({
filePath: toProjectPath('/', '/foo/asset.js'),
env: createEnvironment(),
stats,
type: 'js',
isSource: true,
}),
options: DEFAULT_OPTIONS,
});
asset.addDependency({specifier: './foo', specifierType: 'esm'});
asset.addDependency({
specifier: './foo',
specifierType: 'esm',
env: {context: 'web-worker', engines: {}},
});
let dependencies = asset.getDependencies();
assert(dependencies.length === 2);
});
});