diff --git a/types/video.js/test/plugin-tests.ts b/types/video.js/test/plugin-tests.ts new file mode 100644 index 0000000000..281aa066c2 --- /dev/null +++ b/types/video.js/test/plugin-tests.ts @@ -0,0 +1,33 @@ +import videojs from 'video.js'; + +declare module 'video.js' { + interface VideoJsPlayer { + somePlugin(options?: SomePluginOptions): SomePluginType; + } + + interface VideoJsPlayerPluginOptions { + somePlugin: SomePluginOptions; + } + + interface SomePluginOptions { + test: boolean; + } + + class SomePluginType {} +} + +videojs('example_video_1').somePlugin(); + +videojs('example_video_2', { + autoplay: true, + plugins: { + somePlugin: { + test: true, + }, + someOtherPluginNotTyped: {}, + }, +}); + +videojs('example_video_3', { + plugins: {}, +}); diff --git a/types/video.js/tsconfig.json b/types/video.js/tsconfig.json index 4fa528ab2e..b377b83d22 100644 --- a/types/video.js/tsconfig.json +++ b/types/video.js/tsconfig.json @@ -19,7 +19,7 @@ }, "files": [ "index.d.ts", - "video.js-some-plugin.d.ts", + "test/plugin-tests.ts", "video.js-tests.ts" ] } \ No newline at end of file diff --git a/types/video.js/video.js-some-plugin.d.ts b/types/video.js/video.js-some-plugin.d.ts deleted file mode 100644 index 46c1607eda..0000000000 --- a/types/video.js/video.js-some-plugin.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -// this is not the actual definition file, just an example augmentation -/* tslint:disable:no-self-import no-declare-current-package */ - -import { VideoJsPlayer } from 'video.js'; - -declare module 'video.js' { - interface VideoJsPlayer { - somePluginDefinedInAugmentation(options?: {}): this; - } - - interface VideoJsPlayerPluginOptions { - somePluginDefinedInAugmentation: { - someRequiredProperty: boolean; - }; - } -} diff --git a/types/video.js/video.js-tests.ts b/types/video.js/video.js-tests.ts index 31591efbba..3f75548dd3 100644 --- a/types/video.js/video.js-tests.ts +++ b/types/video.js/video.js-tests.ts @@ -69,8 +69,6 @@ videojs("example_video_1").ready(function() { testPlugin(this, {}); - testAugmentation(this); - testLogger(); }); @@ -120,21 +118,6 @@ function testPlugin(player: videojs.Player, options: {}) { (player as any).uloztoExample(options); } -function testAugmentation(player: videojs.Player) { - player.somePluginDefinedInAugmentation(); - videojs('example_video_2', { - plugins: { - somePluginDefinedInAugmentation: { - someRequiredProperty: true - }, - someOtherPluginNotTyped: {}, - }, - }); - videojs('example_video_3', { - plugins: {} - }); -} - function testLogger() { const mylogger = videojs.log.createLogger('mylogger'); const anotherlogger = mylogger.createLogger('anotherlogger');