Skip to content
Snippets Groups Projects
Commit 8f0279ec authored by Rhys Arkins's avatar Rhys Arkins
Browse files

fix(docker): null is not a valid version

parent ea8bcbc9
No related branches found
No related tags found
No related merge requests found
......@@ -52,6 +52,9 @@ function isLessThanRange(version, range) {
return compare(version, range) < 0;
}
function isValid(version) {
if (!version) {
return null;
}
const parsed = parse(version);
return parsed ? version : null;
}
......
......@@ -4,6 +4,7 @@ const semver = require('../../lib/versioning')('semver');
describe('docker.isValid(input)', () => {
describe('isValid(version)', () => {
it('should support all versions length', () => {
expect(docker.isValid(null)).toBe(null);
expect(docker.isValid('1.2.3')).toBe('1.2.3');
expect(docker.isValid('18.04')).toBe('18.04');
expect(docker.isValid('10.1')).toBe('10.1');
......@@ -11,7 +12,7 @@ describe('docker.isValid(input)', () => {
expect(docker.isValid('foo')).toBe(null);
});
});
describe('isValid(version)', () => {
describe('getMajor(version)', () => {
it('should support all versions length', () => {
expect(docker.getMajor('1.2.3')).toBe(1);
expect(docker.getMajor('18.04')).toBe(18);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment