it('returns string containing name of package when packages contains only one item',()=>{
expect(getPackagesString(examplePackages.slice(0,1),true,3)).toBe('Used by pg');
});
it('returns string with comma separated names of packages up to 3 when `truncate` param is true and packages count exceeds `displayPackageCount`',()=>{
expect(getPackagesString(examplePackages,true,3)).toBe('Used by pg, puma, foo, and ');
});
it('returns string with comma separated names of all the packages when `truncate` param is true and packages count does NOT exceed `displayPackageCount`',()=>{
it('returns string containing name of package when issue.packages contains only one item',(done)=>{
vm.issue=Object.assign({},licenseReportIssue,{
// We need only 3 elements as it is same as
// default value of `displayPackageCount`
// which is 3.
packages:licenseReportIssue.packages.slice(0,1),
});
Vue.nextTick()
.then(()=>{
expect(vm.getPackagesString(true)).toBe('pg');
})
.then(done)
.catch(done.fail);
});
it('returns string with comma separated names of packages up to 3 when `truncate` param is true and issue.packages count exceeds `displayPackageCount`',()=>{
expect(vm.getPackagesString(true)).toBe('pg, puma, foo and ');
});
it('returns string with comma separated names of all the packages when `truncate` param is true and issue.packages count does NOT exceed `displayPackageCount`',(done)=>{
vm.issue=Object.assign({},licenseReportIssue,{
// We need only 3 elements as it is same as
// default value of `displayPackageCount`
// which is 3.
packages:licenseReportIssue.packages.slice(0,3),
});
Vue.nextTick()
.then(()=>{
expect(vm.getPackagesString(true)).toBe('pg, puma and foo');
})
.then(done)
.catch(done.fail);
});
it('returns string with comma separated names of all the packages when `truncate` param is false irrespective of issue.packages count',()=>{
expect(vm.getPackagesString(false)).toBe('pg, puma, foo, bar and baz');
});
});
describe('handleShowPackages',()=>{
it('sets value of `showAllPackages` prop to true',()=>{
vm.showAllPackages=false;
vm.handleShowPackages();
expect(vm.showAllPackages).toBe(true);
});
});
});
describe('template',()=>{
it('renders component container element with class `license-item`',()=>{