Skip to content

Commit

Permalink
loosen the versionPath requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
mattquinlan440 committed Aug 18, 2023
1 parent 7dc65b2 commit bcdda4e
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/dependency-entry/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ describe('DependencyEntry', () => {
expect(ac.assertString).toHaveBeenCalledWith(options.versionPath, 'versionPath');
});

it('should throw if versionPath does not contain {{version}} for mustaching', () => {
it('should not throw if versionPath does not contain {{version}} for mustaching', () => {
options.versionPath = 'versionVersion';

expect(() => new DependencyEntry(options)).toThrowError(/versionPath/);
expect(() => new DependencyEntry(options)).not.toThrowError(/versionPath/);
});

it('should assert es5 is an array of strings', () => {
Expand Down
4 changes: 0 additions & 4 deletions src/external-package-entry/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ export class ExternalPackageEntry {
ac.assertString(repo, 'repo');
ac.assertString(versionPath, 'versionPath');

if(!versionPath.includes('{{version}}')) {
throw new Error(`versionPath must include {{version}} for where the version number should be included. Provided value: ${versionPath}`);
}

if(esm.length === 0 && es5.length === 0) {
throw new Error('Either es5 or esm must be provided, or both.');
}
Expand Down
49 changes: 47 additions & 2 deletions src/external-package-entry/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,16 @@ describe('ExternalPackageEntry', () => {
expect(ac.assertString).toHaveBeenCalledWith(options.versionPath, 'versionPath');
});

it('should throw if versionPath does not contain {{version}} for mustaching', () => {
it('should NOT throw if versionPath does not contain {{version}} for mustaching', () => {
options.versionPath = 'versionVersion';

expect(() => new ExternalPackageEntry(options)).toThrowError(/versionPath/);
expect(() => new ExternalPackageEntry(options)).not.toThrowError(/versionPath/);
});

it('should allow versionPath to contain a string representing a specific version', () => {
options.versionPath = '1.14.0-STARFLEET-1701.D';

expect(() => new ExternalPackageEntry(options)).not.toThrowError(/versionPath/);
});

it('should assert es5 is an array of strings', () => {
Expand Down Expand Up @@ -349,6 +355,19 @@ describe('ExternalPackageEntry', () => {
const expectedUrl = [options.basePath, interpolatedVersion, override.es5[0]].join('');
expect(results).toEqual([ expectedUrl ]);
});

it('should return the built urls for es5 files for explicit versionPath with no mustache', () => {
const version = 'yes.this.version';
const versionPath = 'v' + version;

dependencyEntry = new ExternalPackageEntry({
...options,
versionPath
});
const results = dependencyEntry.getEs5Urls(version);

expect(results).toEqual([ [options.basePath, versionPath, options.es5].join('') ]);
});
});

describe('getEsmUrls', () => {
Expand Down Expand Up @@ -448,6 +467,19 @@ describe('ExternalPackageEntry', () => {
const expectedUrl = [options.basePath, interpolatedVersion, override.esm[0]].join('');
expect(results).toEqual([ expectedUrl ]);
});

it('should return the built urls for esm files for explicit versionPath with no mustache', () => {
const version = 'yes.this.version';
const versionPath = 'v' + version;

dependencyEntry = new ExternalPackageEntry({
...options,
versionPath
});
const results = dependencyEntry.getEsmUrls(version);

expect(results).toEqual([ [options.basePath, versionPath, options.esm].join('') ]);
});
});

describe('getCssUrls', () => {
Expand Down Expand Up @@ -548,5 +580,18 @@ describe('ExternalPackageEntry', () => {
const expectedUrl = [options.basePath, interpolatedVersion, override.css[0]].join('');
expect(results).toEqual([ expectedUrl ]);
});

it('should return the built urls for css files for explicit versionPath with no mustache', () => {
const version = 'yes.this.version';
const versionPath = 'v' + version;

dependencyEntry = new ExternalPackageEntry({
...options,
versionPath
});
const results = dependencyEntry.getCssUrls(version);

expect(results).toEqual([ [options.basePath, versionPath, options.css].join('') ]);
});
});
});

0 comments on commit bcdda4e

Please sign in to comment.