[video.js] change plugin test so that it does not include the test plugin in the types (#39915)

* all plugins are optional, so plugins option should be a Partial<>

* fix whitespace

* fix plugin test so that the test plugin isn't packaged w/ types
This commit is contained in:
Joe Flateau 2019-10-30 11:05:37 -04:00 committed by Jesse Trinity
parent 92e12e8810
commit bb58538ffb
4 changed files with 34 additions and 34 deletions

View File

@ -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: {},
});

View File

@ -19,7 +19,7 @@
},
"files": [
"index.d.ts",
"video.js-some-plugin.d.ts",
"test/plugin-tests.ts",
"video.js-tests.ts"
]
}

View File

@ -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;
};
}
}

View File

@ -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');