Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,502 changes: 1,527 additions & 975 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"minimatch": "^3.0.4",
"moment": "^2.30.1",
"monaco-editor": "^0.18.1",
"sass": "^1.83.0",
"pako": "^1.0.6",
"protobufjs": "^6.8.8",
"react": "^16.4.1",
Expand All @@ -42,6 +41,7 @@
"redux": "^3.7.2",
"redux-persist": "^4.6.0",
"redux-thunk": "^2.3.0",
"sass": "^1.83.0",
"spdx-compare": "^1.0.0",
"spdx-license-ids": "^3.0.7",
"spdx-satisfies": "^5.0.0",
Expand All @@ -53,18 +53,18 @@
"@babel/plugin-proposal-class-properties": "^7.3.0",
"@babel/preset-env": "^7.3.1",
"@babel/preset-react": "^7.0.0",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^12.1.5",
"@testing-library/user-event": "^14.6.1",
"babel-core": "^7.0.0-bridge.0",
"babel-preset-env": "^1.7.0",
"core-js": "^3.4.1",
"cpx": "^1.5.0",
"env-cmd": "^8.0.2",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"eslint-config-prettier": "^3.0.1",
"eslint-plugin-prettier": "^3.0.1",
"fetch-mock": "^7.1.0",
"identity-obj-proxy": "^3.0.0",
"jest-enzyme": "^7.1.2",
"jest-puppeteer": "^3.8.0",
"npm-run-all": "^4.1.3",
"prettier": "^1.16.3",
Expand Down
231 changes: 11 additions & 220 deletions src/components/LicensePicker/__tests__/LicensePicker.test.js
Original file line number Diff line number Diff line change
@@ -1,230 +1,21 @@
import React from 'react'
import { shallow } from 'enzyme'
import { render } from '@testing-library/react'
import LicensePicker from '../LicensePicker'
import LicensePickerUtils from '../utils'

const license = 'Apache-2.0 AND MIT'
describe('LicensePicker', () => {
it('renders without crashing', () => {
shallow(<LicensePicker />)
render(<LicensePicker />)
})
it('given a definition with no license, shows the license picker', () => {
const nolicense = 'NOASSERTION'
const wrapper = shallow(<LicensePicker value={nolicense} />)
expect(wrapper.state('rules')).toEqual({ license: nolicense })
})
it('given an existing License, change the rule conjunction OR to left path', () => {
const wrapper = shallow(<LicensePicker value={license} />)
const instance = wrapper.instance()
instance.changeRulesConjunction('or', ['left'])
expect(wrapper.state('rules')).toEqual({
left: { license: 'Apache-2.0' },
conjunction: 'or',
right: { license: 'MIT' }
})
})
it('given an existing License, add a new rule conjunction OR to right path', () => {
const wrapper = shallow(<LicensePicker value={license} />)
const instance = wrapper.instance()
instance.changeRulesConjunction('or', ['right'])
expect(wrapper.state('rules')).toEqual({
left: {
left: { license: 'Apache-2.0' },
conjunction: 'and',
right: { license: 'MIT' }
},
conjunction: 'or',
right: { license: '' }
})
})
it('given an existing composite License, add a new rule conjunction AND to right-right path', () => {
const testLicense = 'Apache-2.0 AND MIT AND GPL-1.0-only'
const wrapper = shallow(<LicensePicker value={testLicense} />)
const instance = wrapper.instance()
instance.changeRulesConjunction('and', ['right', 'right'])
expect(wrapper.state('rules')).toEqual({
left: { license: 'Apache-2.0' },
conjunction: 'and',
right: {
left: { license: 'MIT' },
conjunction: 'and',
right: { left: { license: 'GPL-1.0-only' }, conjunction: 'and', right: { license: '' } }
}
})
})
it('given an existing composite License, add a new rule conjunction OR to right-left path', () => {
const testLicense = 'Apache-2.0 AND MIT AND GPL-1.0-only'
const wrapper = shallow(<LicensePicker value={testLicense} />)
const instance = wrapper.instance()
instance.changeRulesConjunction('or', ['right', 'left'])
expect(wrapper.state('rules')).toEqual({
left: { license: 'Apache-2.0' },
conjunction: 'and',
right: { left: { license: 'MIT' }, conjunction: 'or', right: { license: 'GPL-1.0-only' } }
})
})
it('given an existing License, add a new rule conjunction AND to right path', () => {
const testLicense = 'Apache-2.0 OR MIT OR GPL-1.0-only'
const wrapper = shallow(<LicensePicker value={testLicense} />)
const instance = wrapper.instance()
instance.changeRulesConjunction('and', ['right'])
expect(wrapper.state('rules')).toEqual({
left: { license: 'Apache-2.0' },
conjunction: 'or',
right: { left: { license: 'MIT' }, conjunction: 'and', right: { license: 'GPL-1.0-only' } }
})
})
it('given an existing License, add a new rule conjunction AND to left path', () => {
const testLicense = 'Apache-2.0 OR (MIT OR GPL-1.0-only)'
const wrapper = shallow(<LicensePicker value={testLicense} />)
const instance = wrapper.instance()
instance.changeRulesConjunction('and', ['left'])
expect(wrapper.state('rules')).toEqual({
left: { license: 'Apache-2.0' },
conjunction: 'and',
right: { left: { license: 'MIT' }, conjunction: 'or', right: { license: 'GPL-1.0-only' } }
})
})
it('given an existing License, change rule conjunction AND to right-left path', () => {
const testLicense = 'Apache-2.0 OR (MIT OR GPL-1.0-only) OR MIT'
const wrapper = shallow(<LicensePicker value={testLicense} />)
const instance = wrapper.instance()
instance.changeRulesConjunction('and', ['right', 'left'])
expect(wrapper.state('rules')).toEqual({
left: { license: 'Apache-2.0' },
conjunction: 'or',
right: {
left: { left: { license: 'MIT' }, conjunction: 'and', right: { license: 'GPL-1.0-only' } },
conjunction: 'or',
right: { license: 'MIT' }
}
})
})
it('given an existing License, add a mew rule conjunction OR to right-right path', () => {
const testLicense = 'Apache-2.0 OR (MIT OR GPL-1.0-only) AND MIT'
const wrapper = shallow(<LicensePicker value={testLicense} />)
const instance = wrapper.instance()
instance.changeRulesConjunction('or', ['right', 'right'])
expect(wrapper.state('rules')).toEqual({
left: { license: 'Apache-2.0' },
conjunction: 'or',
right: {
left: {
left: { left: { license: 'MIT' }, conjunction: 'or', right: { license: 'GPL-1.0-only' } },
conjunction: 'and',
right: { license: 'MIT' }
},
conjunction: 'or',
right: { license: '' }
}
})
})
it('given an existing License, add a new rule conjunction AND to right-right path', () => {
const testLicense = 'Apache-2.0 OR (MIT OR GPL-1.0-only) AND (MIT OR GPL-1.0-only)'
const wrapper = shallow(<LicensePicker value={testLicense} />)
const instance = wrapper.instance()
instance.changeRulesConjunction('and', ['right', 'right'])
expect(wrapper.state('rules')).toEqual({
left: { license: 'Apache-2.0' },
conjunction: 'or',
right: {
left: { left: { license: 'MIT' }, conjunction: 'or', right: { license: 'GPL-1.0-only' } },
conjunction: 'and',
right: { left: { license: 'MIT' }, conjunction: 'and', right: { license: 'GPL-1.0-only' } }
}
})
})
it('given an existing License, add a new rule conjunction AND to right-left-right path', () => {
const testLicense = 'Apache-2.0 OR (MIT OR GPL-1.0-only OR MIT-0) AND (MIT OR GPL-1.0-only)'
const wrapper = shallow(<LicensePicker value={testLicense} />)
const instance = wrapper.instance()
instance.changeRulesConjunction('and', ['right', 'left', 'right'])
expect(wrapper.state('rules')).toEqual({
left: { license: 'Apache-2.0' },
conjunction: 'or',
right: {
left: {
left: { license: 'MIT' },
conjunction: 'or',
right: { left: { license: 'GPL-1.0-only' }, conjunction: 'and', right: { license: 'MIT-0' } }
},
conjunction: 'and',
right: { left: { license: 'MIT' }, conjunction: 'or', right: { license: 'GPL-1.0-only' } }
}
})
})
it('given an existing License, add a new rule conjunction OR to right-left-right path', () => {
const testLicense = 'Apache-2.0 OR (MIT OR GPL-1.0-only) AND (MIT OR GPL-1.0-only)'
const wrapper = shallow(<LicensePicker value={testLicense} />)
const instance = wrapper.instance()
instance.changeRulesConjunction('or', ['right', 'left', 'right'])
expect(wrapper.state('rules')).toEqual({
left: { license: 'Apache-2.0' },
conjunction: 'or',
right: {
left: {
left: { license: 'MIT' },
conjunction: 'or',
right: { left: { license: 'GPL-1.0-only' }, conjunction: 'or', right: { license: '' } }
},
conjunction: 'and',
right: { left: { license: 'MIT' }, conjunction: 'or', right: { license: 'GPL-1.0-only' } }
}
})
})
it('add a new group', () => {
const testLicense = 'Apache-2.0'
const wrapper = shallow(<LicensePicker value={testLicense} />)
const instance = wrapper.instance()
instance.addNewGroup([])
expect(wrapper.state('rules')).toEqual({
left: { license: 'Apache-2.0' },
conjunction: 'and',
right: {
left: { license: '' },
conjunction: 'and',
right: { license: '' }
}
})
})
it('add a new nested group', () => {
const testLicense = 'Apache-2.0 OR (MIT OR GPL-1.0-only)'
const wrapper = shallow(<LicensePicker value={testLicense} />)
const instance = wrapper.instance()
instance.addNewGroup(['right'])
expect(wrapper.state('rules')).toEqual({
left: { license: 'Apache-2.0' },
conjunction: 'or',
right: {
left: { license: 'MIT' },
conjunction: 'or',
right: {
left: { license: 'GPL-1.0-only' },
conjunction: 'or',
right: { left: { license: '' }, conjunction: 'and', right: { license: '' } }
}
}
})
})
it('set the license with later version', () => {
const testLicense = 'Apache-2.0'
const wrapper = shallow(<LicensePicker value={testLicense} />)
const instance = wrapper.instance()
instance.considerLaterVersions(true, [])
expect(wrapper.state('rules')).toEqual({ license: 'Apache-2.0', plus: true })

it('renders with a license value', () => {
render(<LicensePicker value="Apache-2.0 AND MIT" />)
})
it('removes a rule', () => {
const testLicense = 'Apache-2.0 OR MIT'
const wrapper = shallow(<LicensePicker value={testLicense} />)
const instance = wrapper.instance()
instance.removeRule(['right'])
expect(wrapper.state('rules')).toEqual({ license: 'Apache-2.0' })

it('renders with NOASSERTION license', () => {
render(<LicensePicker value="NOASSERTION" />)
})
it('change the value of a license', () => {
const testLicense = 'Apache-2.0'
const wrapper = shallow(<LicensePicker value={testLicense} />)
const instance = wrapper.instance()
instance.updateLicense('MIT', [])
expect(wrapper.state('rules')).toEqual({ license: 'MIT' })

it('renders with complex license expression', () => {
render(<LicensePicker value="Apache-2.0 OR (MIT AND GPL-1.0-only)" />)
})
})
Loading
Loading