Skip to content

Commit

Permalink
Merge pull request #2447 from benedikt-richter/prefer_license_over_co…
Browse files Browse the repository at this point in the history
…pyright_in_package_card

Prefer license name over copyright in package card
  • Loading branch information
benedikt-richter committed Dec 22, 2023
2 parents 09129b1 + 5fb0cc6 commit 489b110
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
20 changes: 16 additions & 4 deletions src/Frontend/util/__tests__/get-card-labels.test.ts
Expand Up @@ -76,51 +76,60 @@ describe('Test getPackageLabel', () => {
it('finds label for package', () => {
expect(getCardLabels(testProps)).toEqual([
'Test package name, 1.2',
'(c) Test copyright',
'Test license name',
]);
});

it('finds label for package without version', () => {
expect(getCardLabels(testPropsWithoutVersion)).toEqual([
'Test package name',
'(c) Test copyright',
'Test license name',
]);
});

it('finds label for package with undefined name', () => {
expect(getCardLabels(testPropsWithUndefinedName)).toEqual([
'Test url',
'(c) Test copyright',
'Test license name',
]);
});

it('finds label for package without name', () => {
expect(getCardLabels(testPropsWithoutName)).toEqual([
'Test url',
'(c) Test copyright',
'Test license name',
]);
});

it('finds label for package with only copyright, licenseText and comment', () => {
expect(getCardLabels(testPropsCopyrightLicenseTextAndComment)).toEqual([
'(c) Test copyright',
'Test license text',
]);
});

it('finds label for package with license text and comment', () => {
expect(getCardLabels(testPropsWithLicenseTextAndComment)).toEqual([
'Test license text',
'Test comment',
]);
});

it('finds label for package with just comment', () => {
expect(getCardLabels(testPropsJustComment)).toEqual(['Test comment']);
});

it('finds label for empty package', () => {
expect(getCardLabels(EMPTY_DISPLAY_PACKAGE_INFO)).toEqual([]);
});

it('finds label for package with just url and copyright', () => {
expect(getCardLabels(testPropsJustUrlAndCopyright)).toEqual([
'Test url',
'(c) Test copyright',
]);
});

it('finds label for package with just first party', () => {
expect(getCardLabels(testPropsJustFirstParty)).toEqual(['First party']);
});
Expand Down Expand Up @@ -156,6 +165,7 @@ describe('Test addFirstLineOfPackageLabelFromAttribute', () => {
);
expect(testPackageLabels).toEqual(['Test package name, 1.2']);
});

it('adds name without version', () => {
const testPackageLabels: Array<string> = [];
addFirstLineOfPackageLabelFromAttribute(
Expand All @@ -165,6 +175,7 @@ describe('Test addFirstLineOfPackageLabelFromAttribute', () => {
);
expect(testPackageLabels).toEqual(['Test package name']);
});

it('adds copyright', () => {
const testPackageLabels: Array<string> = [];
addFirstLineOfPackageLabelFromAttribute(
Expand All @@ -174,6 +185,7 @@ describe('Test addFirstLineOfPackageLabelFromAttribute', () => {
);
expect(testPackageLabels).toEqual(['(c) Test copyright']);
});

it('adds url', () => {
const testPackageLabels: Array<string> = [];
addFirstLineOfPackageLabelFromAttribute(
Expand Down
2 changes: 1 addition & 1 deletion src/Frontend/util/get-card-labels.ts
Expand Up @@ -13,7 +13,7 @@ type RelevantDisplayPackageInfoAttributes =
| 'url';

const PRIORITIZED_DISPLAY_PACKAGE_INFO_ATTRIBUTES: Array<RelevantDisplayPackageInfoAttributes> =
['packageName', 'copyright', 'licenseName', 'licenseText', 'comments', 'url'];
['packageName', 'licenseName', 'copyright', 'licenseText', 'comments', 'url'];

const FIRST_PARTY_TEXT = 'First party';

Expand Down

0 comments on commit 489b110

Please sign in to comment.