Skip to content

Commit

Permalink
fix(youtube-player): compatibility with latest typings (angular#22223)
Browse files Browse the repository at this point in the history
Updates the `youtube-player` package to the latest typings and resolves a test failure.
  • Loading branch information
crisbeto authored Mar 29, 2021
1 parent 9528120 commit 0c83adc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@angular/forms": "^12.0.0-next.5",
"@angular/platform-browser": "^12.0.0-next.5",
"@types/googlemaps": "^3.43.1",
"@types/youtube": "^0.0.40",
"@types/youtube": "^0.0.42",
"@webcomponents/custom-elements": "^1.1.0",
"core-js-bundle": "^3.8.2",
"material-components-web": "11.0.0-canary.0cde52f5a.0",
Expand Down
11 changes: 9 additions & 2 deletions src/youtube-player/fake-youtube-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

// A re-creation of YT.PlayerState since enum values cannot be bound to the window
// object.
// A re-creation of YT.PlayerState since enum values cannot be bound to the window object.
const playerState = {
UNSTARTED: -1,
ENDED: 0,
Expand All @@ -17,6 +16,13 @@ const playerState = {
CUED: 5,
};

// Re-creation of `YT.ModestBranding` since it was changed
// to a plain enum which we can't reference in tests.
const modestBranding = {
Full: 0,
Modest: 1
};

interface FakeYtNamespace {
playerCtorSpy: jasmine.Spy;
playerSpy: jasmine.SpyObj<YT.Player>;
Expand Down Expand Up @@ -84,6 +90,7 @@ export function createFakeYtNamespace(): FakeYtNamespace {
namespace: {
'Player': playerCtorSpy as unknown as typeof YT.Player,
'PlayerState': playerState,
'ModestBranding': modestBranding
} as typeof YT,
};
}
2 changes: 1 addition & 1 deletion src/youtube-player/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"homepage": "https://github.com/angular/components/tree/master/src/youtube-player#readme",
"dependencies": {
"@types/youtube": "^0.0.38",
"@types/youtube": "^0.0.42",
"tslib": "0.0.0-TSLIB"
},
"peerDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2220,10 +2220,10 @@
dependencies:
yaml "*"

"@types/youtube@^0.0.40":
version "0.0.40"
resolved "https://registry.yarnpkg.com/@types/youtube/-/youtube-0.0.40.tgz#93502cc42e4ce06a59db1e2d6fd986260dca31d3"
integrity sha512-gMiHfad1VGQ7CoXkhrjWiROPpLTSJydvBO73Z9JIIZ+FpZ2BX9q9Zf/tanP+KUTFoKUqHVv6+xt7sF2gztQ4Og==
"@types/youtube@^0.0.42":
version "0.0.42"
resolved "https://registry.yarnpkg.com/@types/youtube/-/youtube-0.0.42.tgz#c3568e3e82e04cbd00cac3b66564ebcd21fd9d90"
integrity sha512-Nqo3HMPFPcNyZ7HNFZJjpH+N4yXqpxBItG+41e7nL9zednovMRZMXWj36CctSznbBcbj6ucvkJDo5iZ8SKqLIw==

"@typescript-eslint/[email protected]":
version "4.14.0"
Expand Down

0 comments on commit 0c83adc

Please sign in to comment.