1
1
/* eslint-env qunit */
2
+ import sinon from 'sinon' ;
3
+ import log from '../../src/js/utils/log' ;
2
4
import Player from '../../src/js/player' ;
3
5
import Plugin from '../../src/js/plugin' ;
4
6
@@ -53,12 +55,6 @@ QUnit.test('registerPlugin() illegal arguments', function(assert) {
53
55
'plugins must have a name'
54
56
) ;
55
57
56
- assert . throws (
57
- ( ) => Plugin . registerPlugin ( 'play' ) ,
58
- new Error ( 'Illegal plugin name, "play", already exists.' ) ,
59
- 'plugins cannot share a name with an existing player method'
60
- ) ;
61
-
62
58
assert . throws (
63
59
( ) => Plugin . registerPlugin ( 'foo' ) ,
64
60
new Error ( 'Illegal plugin for "foo", must be a function, was undefined.' ) ,
@@ -70,6 +66,18 @@ QUnit.test('registerPlugin() illegal arguments', function(assert) {
70
66
new Error ( 'Illegal plugin for "foo", must be a function, was object.' ) ,
71
67
'plugins must be functions'
72
68
) ;
69
+
70
+ assert . throws (
71
+ ( ) => Plugin . registerPlugin ( 'play' , function ( ) { } ) ,
72
+ new Error ( 'Illegal plugin name, "play", cannot share a name with an existing player method!' ) ,
73
+ 'plugins must be functions'
74
+ ) ;
75
+
76
+ sinon . spy ( log , 'warn' ) ;
77
+ Plugin . registerPlugin ( 'foo' , function ( ) { } ) ;
78
+ Plugin . registerPlugin ( 'foo' , function ( ) { } ) ;
79
+ assert . strictEqual ( log . warn . callCount , 1 , 'warn on re-registering a plugin' ) ;
80
+ log . warn . restore ( ) ;
73
81
} ) ;
74
82
75
83
QUnit . test ( 'getPlugin()' , function ( assert ) {
0 commit comments