Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(cli): add test for compare-plugins plugin-helpers #8064

Merged
merged 1 commit into from
Oct 21, 2021
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import * as path from 'path';
import { PluginInfo } from '../../domain/plugin-info';
import { PluginManifest } from '../../domain/plugin-manifest';
import { twoPluginsAreTheSame } from '../../plugin-helpers/compare-plugins';

describe('compare-plugins', () => {
describe('twoPluginsAreTheSame', () => {
it('returns true when packageLocation is same', () => {
const p1 = new PluginInfo(
'amplify-util-plugin',
'1.0.0',
path.join('path', 'to', 'package@1.0.0'),
new PluginManifest('util-plugin', 'util'),
);
const p2 = new PluginInfo(
'amplify-util-plugin',
'1.0.0',
path.join('path', 'to', 'package@1.0.0'),
new PluginManifest('util-plugin', 'util'),
);
expect(twoPluginsAreTheSame(p1, p2)).toBe(true);
});

it('returns true when both packageName and packageVersion is same', () => {
const p1 = new PluginInfo(
'amplify-util-plugin',
'1.0.0',
path.join('path', 'to', 'package1'),
new PluginManifest('util-plugin', 'util'),
);
const p2 = new PluginInfo(
'amplify-util-plugin',
'1.0.0',
path.join('path', 'to', 'package2'),
new PluginManifest('util-plugin', 'util'),
);
expect(twoPluginsAreTheSame(p1, p2)).toBe(true);
});

it('returns false when packageLocation, packageName and packageVersion is not same', () => {
const p1 = new PluginInfo(
'amplify-util-plugin',
'1.0.0',
path.join('path', 'to', 'package1'),
new PluginManifest('util-plugin', 'util'),
);
const p2 = new PluginInfo(
'amplify-util-plugin',
'2.0.0',
path.join('path', 'to', 'package2'),
new PluginManifest('util-plugin', 'util'),
);
expect(twoPluginsAreTheSame(p1, p2)).toBe(false);
});
});
});