-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Replace legacy components - Update tests - Add version utils - Add grafana/experimental
- Loading branch information
Showing
7 changed files
with
264 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import { Divider as GrafanaDivider, useTheme2 } from '@grafana/ui'; | ||
import { config } from '@grafana/runtime'; | ||
import { isVersionGtOrEq } from '../utils/version'; | ||
|
||
export function Divider() { | ||
const theme = useTheme2(); | ||
return isVersionGtOrEq(config.buildInfo.version, '10.1.0') ? ( | ||
<GrafanaDivider /> | ||
) : ( | ||
<div | ||
style={{ borderTop: `1px solid ${theme.colors.border.weak}`, margin: theme.spacing(2, 0), width: '100%' }} | ||
></div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { SemVersion, isVersionGtOrEq } from './version' | ||
|
||
describe('SemVersion', () => { | ||
let version = '1.0.0-alpha.1' | ||
|
||
describe('parsing', () => { | ||
it('should parse version properly', () => { | ||
const semver = new SemVersion(version) | ||
expect(semver.major).toBe(1) | ||
expect(semver.minor).toBe(0) | ||
expect(semver.patch).toBe(0) | ||
expect(semver.meta).toBe('alpha.1') | ||
}) | ||
}) | ||
|
||
describe('comparing', () => { | ||
beforeEach(() => { | ||
version = '3.4.5' | ||
}) | ||
|
||
it('should detect greater version properly', () => { | ||
const semver = new SemVersion(version) | ||
const cases = [ | ||
{ value: '3.4.5', expected: true }, | ||
{ value: '3.4.4', expected: true }, | ||
{ value: '3.4.6', expected: false }, | ||
{ value: '4', expected: false }, | ||
{ value: '3.5', expected: false }, | ||
] | ||
cases.forEach((testCase) => { | ||
expect(semver.isGtOrEq(testCase.value)).toBe(testCase.expected) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('isVersionGtOrEq', () => { | ||
it('should compare versions properly (a >= b)', () => { | ||
const cases = [ | ||
{ values: ['3.4.5', '3.4.5'], expected: true }, | ||
{ values: ['3.4.5', '3.4.4'], expected: true }, | ||
{ values: ['3.4.5', '3.4.6'], expected: false }, | ||
{ values: ['3.4', '3.4.0'], expected: true }, | ||
{ values: ['3', '3.0.0'], expected: true }, | ||
{ values: ['3.1.1-beta1', '3.1'], expected: true }, | ||
{ values: ['3.4.5', '4'], expected: false }, | ||
{ values: ['3.4.5', '3.5'], expected: false }, | ||
{ values: ['6.0.0', '5.2.0'], expected: true }, | ||
] | ||
cases.forEach((testCase) => { | ||
expect(isVersionGtOrEq(testCase.values[0], testCase.values[1])).toBe(testCase.expected) | ||
}) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.