Skip to content

Commit

Permalink
fix(#596): fix issue with semver in latest cht versions
Browse files Browse the repository at this point in the history
fix(#596): fix issue with semver in latest cht versions
  • Loading branch information
1yuv authored Jan 10, 2024
1 parent bf7f647 commit 86a9954
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/lib/get-api-version.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const sinon = require('sinon');
const rewire = require('rewire');
const { expect } = require('chai');
const apiVersion = rewire('../../src/lib/get-api-version');


describe('get-api-version', () => {
afterEach(() => {
sinon.reset();
});

const versions = [
{ coreVersion: '4.5.0', validVersion: '4.5.0' },
{ coreVersion: '4.5.0.6922454971', validVersion: '4.5.0' },
{ coreVersion: '4.5.1.6922454971', validVersion: '4.5.1' },
{ coreVersion: 'feature-release', validVersion: null },
{ coreVersion: 'test release for 4.5.0', validVersion: '4.5.0' },
{ coreVersion: '4.5.0-feature-release', validVersion: '4.5.0' },
{ coreVersion: '4.2.0-dev.1682192676689', validVersion: '4.2.0' },
];

for (const version of versions) {
it(JSON.stringify(version), async () => {
const mock = {
getApiVersion: sinon.stub().resolves(version.coreVersion),
};
apiVersion.__set__(mock);
const op = await apiVersion.getValidApiVersion();
expect(op).to.equal(version.validVersion);
});
}

});

0 comments on commit 86a9954

Please sign in to comment.