You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: test/magicpen.spec.js
+52
Original file line number
Diff line number
Diff line change
@@ -102,6 +102,7 @@ describe('magicpen', function () {
102
102
},'to throw','Plugins must be functions or adhere to the following interface\n'+
103
103
'{\n'+
104
104
' name: <an optional plugin name>,\n'+
105
+
' version: <an optional semver version string>,\n'+
105
106
' dependencies: <an optional list of dependencies>,\n'+
106
107
' installInto: <a function that will update the given magicpen instance>\n'+
107
108
'}');
@@ -214,6 +215,57 @@ describe('magicpen', function () {
214
215
pen.use(plugin);
215
216
expect(callCount,'to be',1);
216
217
});
218
+
219
+
it('installing two different plugins that are identically named and have the same version (but not ===) will only install the first one',function(){
220
+
varcallCount1=0;
221
+
varplugin1={
222
+
name: 'plugin',
223
+
version: '1.2.3',
224
+
installInto: function(){
225
+
callCount1+=1;
226
+
}
227
+
};
228
+
varcallCount2=0;
229
+
varplugin2={
230
+
name: 'plugin',
231
+
version: '1.2.3',
232
+
installInto: function(){
233
+
callCount2+=1;
234
+
}
235
+
};
236
+
pen.use(plugin1).use(plugin2);
237
+
expect(callCount1,'to be',1);
238
+
expect(callCount2,'to be',0);
239
+
});
240
+
241
+
it('should throw an error when installing two different plugins that are identically named and have different versions',function(){
242
+
pen.use({
243
+
name: 'plugin',
244
+
version: '1.2.3',
245
+
installInto: function(){}
246
+
});
247
+
expect(function(){
248
+
pen.use({
249
+
name: 'plugin',
250
+
version: '1.5.6',
251
+
installInto: function(){}
252
+
});
253
+
},'to throw',"Another instance of the plugin 'plugin' is already installed (version 1.2.3, trying to install 1.5.6). Please check your node_modules folder for unmet peerDependencies.");
254
+
});
255
+
256
+
it('should throw an error when two identically named plugins where the first one has a version number',function(){
257
+
pen.use({
258
+
name: 'plugin',
259
+
version: '1.2.3',
260
+
installInto: function(){}
261
+
});
262
+
expect(function(){
263
+
pen.use({
264
+
name: 'plugin',
265
+
installInto: function(){}
266
+
});
267
+
},'to throw',"Another instance of the plugin 'plugin' is already installed (version 1.2.3). Please check your node_modules folder for unmet peerDependencies.");
0 commit comments