@gcorevideo/player 2.25.6 → 2.25.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,12 @@
1
1
  import { Events, UICorePlugin, template } from '@clappr/core';
2
2
  import assert from 'assert';
3
+ // import { trace } from '@gcorevideo/utils'
3
4
  import { CLAPPR_VERSION } from '../../build.js';
4
5
  import pluginHtml from '../../../assets/audio-tracks/template.ejs';
5
- import '../../../assets/audio-tracks/style.scss';
6
6
  import audioArrow from '../../../assets/icons/old/quality-arrow.svg';
7
7
  import { ExtendedEvents } from '../media-control/MediaControl.js';
8
- import { trace } from '@gcorevideo/utils';
9
8
  const VERSION = '2.22.4';
10
- const T = 'plugins.audiotracks';
9
+ // const T = 'plugins.audiotracks'
11
10
  /**
12
11
  * `PLUGIN` that makes possible to switch audio tracks via the media control UI.
13
12
  * @beta
@@ -20,6 +19,7 @@ const T = 'plugins.audiotracks';
20
19
  */
21
20
  export class AudioTracks extends UICorePlugin {
22
21
  currentTrack = null;
22
+ open = false;
23
23
  tracks = [];
24
24
  /**
25
25
  * @internal
@@ -45,7 +45,7 @@ export class AudioTracks extends UICorePlugin {
45
45
  */
46
46
  get attributes() {
47
47
  return {
48
- class: 'media-control-audiotracks',
48
+ class: 'media-control-audiotracks media-control-dd__wrap',
49
49
  };
50
50
  }
51
51
  /**
@@ -53,8 +53,8 @@ export class AudioTracks extends UICorePlugin {
53
53
  */
54
54
  get events() {
55
55
  return {
56
- 'click [data-audiotracks-select]': 'onTrackSelect',
57
- 'click #audiotracks-button': 'toggleMenu',
56
+ 'click #gplayer-audiotracks-menu [data-item]': 'onTrackSelect',
57
+ 'click #gplayer-audiotracks-button': 'toggleMenu',
58
58
  };
59
59
  }
60
60
  /**
@@ -68,8 +68,9 @@ export class AudioTracks extends UICorePlugin {
68
68
  const mediaControl = this.core.getPlugin('media_control');
69
69
  assert(mediaControl, 'media_control plugin is required');
70
70
  this.listenTo(mediaControl, Events.MEDIACONTROL_RENDERED, () => {
71
- mediaControl.slot('audiotracks', this.$el);
71
+ this.mount();
72
72
  });
73
+ // TODO when tracks change, re-render and re-attach
73
74
  this.listenTo(mediaControl, Events.MEDIACONTROL_HIDE, this.hideMenu);
74
75
  this.listenTo(mediaControl, ExtendedEvents.MEDIACONTROL_MENU_COLLAPSE, (from) => {
75
76
  if (from !== this.name) {
@@ -84,6 +85,7 @@ export class AudioTracks extends UICorePlugin {
84
85
  tracks.find((track) => track.kind === 'main') ?? null; // TODO test
85
86
  this.tracks = tracks;
86
87
  this.render();
88
+ this.mount();
87
89
  });
88
90
  this.listenTo(this.core.activeContainer, Events.CONTAINER_AUDIO_CHANGED, (track) => {
89
91
  this.currentTrack = track;
@@ -91,6 +93,10 @@ export class AudioTracks extends UICorePlugin {
91
93
  this.buttonElement().removeClass('changing');
92
94
  this.updateText();
93
95
  });
96
+ // TODO test
97
+ this.listenTo(this.core.activeContainer, Events.CONTAINER_CLICK, () => {
98
+ this.hideMenu();
99
+ });
94
100
  }
95
101
  shouldRender() {
96
102
  // Render is called from the parent class constructor so tracks aren't available
@@ -101,21 +107,19 @@ export class AudioTracks extends UICorePlugin {
101
107
  * @internal
102
108
  */
103
109
  render() {
104
- if (!this.shouldRender()) {
105
- return this;
106
- }
107
110
  this.$el.html(AudioTracks.template({
108
- tracks: this.tracks,
111
+ tracks: this.tracks ?? [],
109
112
  title: this.getTitle(),
110
113
  icon: audioArrow,
111
114
  current: this.currentTrack?.id,
112
115
  }));
116
+ this.$el.find('#gplayer-audiotracks-menu').hide();
113
117
  this.updateText();
114
118
  this.highlightCurrentTrack();
115
119
  return this;
116
120
  }
117
121
  onTrackSelect(event) {
118
- const id = event.currentTarget?.dataset?.audiotracksSelect;
122
+ const id = event.currentTarget?.dataset?.item;
119
123
  if (id) {
120
124
  this.selectAudioTrack(id);
121
125
  }
@@ -129,25 +133,34 @@ export class AudioTracks extends UICorePlugin {
129
133
  this.updateText();
130
134
  }
131
135
  hideMenu() {
132
- trace(`${T} hideMenu`);
133
- this.$el.find('#audiotracks-select').addClass('hidden');
134
- this.$el.find('#audiotracks-button').attr('aria-expanded', 'false');
136
+ this.open = false;
137
+ this.$el.find('#gplayer-audiotracks-menu').hide();
138
+ this.$el.find('#gplayer-audiotracks-button').attr('aria-expanded', 'false');
135
139
  }
136
140
  toggleMenu() {
137
- this.core.getPlugin('media_control').trigger(ExtendedEvents.MEDIACONTROL_MENU_COLLAPSE, this.name);
138
- this.$el.find('#audiotracks-select').toggleClass('hidden'); // TODO use plain CSS display: none
139
- const open = !this.$el.find('#audiotracks-select').hasClass('hidden'); // TODO hold state
140
- this.$el.find('#audiotracks-button').attr('aria-expanded', open);
141
+ this.open = !this.open;
142
+ this.core
143
+ .getPlugin('media_control')
144
+ .trigger(ExtendedEvents.MEDIACONTROL_MENU_COLLAPSE, this.name);
145
+ if (this.open) {
146
+ this.$el.find('#gplayer-audiotracks-menu').show();
147
+ }
148
+ else {
149
+ this.$el.find('#gplayer-audiotracks-menu').hide();
150
+ }
151
+ this.$el
152
+ .find('#gplayer-audiotracks-button')
153
+ .attr('aria-expanded', this.open);
141
154
  }
142
155
  buttonElement() {
143
- return this.$('button');
156
+ return this.$('#gplayer-audiotracks-button');
144
157
  }
145
158
  buttonElementText() {
146
- return this.$('button .audio-text');
159
+ return this.$el.find('#gplayer-audiotracks-button-text');
147
160
  }
148
161
  trackElement(id) {
149
- return this.$('#audiotracks-select a' +
150
- (id !== undefined ? `[data-audiotracks-select="${id}"]` : '')).parent();
162
+ return this.$('#gplayer-audiotracks-menu a' +
163
+ (id !== undefined ? `[data-item="${id}"]` : '')).parent();
151
164
  }
152
165
  getTitle() {
153
166
  if (!this.currentTrack) {
@@ -178,4 +191,9 @@ export class AudioTracks extends UICorePlugin {
178
191
  .attr('aria-checked', 'true');
179
192
  }
180
193
  }
194
+ mount() {
195
+ if (this.shouldRender()) {
196
+ this.core.getPlugin('media_control')?.slot('audiotracks', this.$el);
197
+ }
198
+ }
181
199
  }
@@ -888,7 +888,7 @@ export class MediaControl extends UICorePlugin {
888
888
  const panel = this.getElementLocation(name);
889
889
  if (panel) {
890
890
  element.attr(`data-${name}`, '');
891
- element.addClass('gplayer-mc-panel-item');
891
+ element.addClass('media-control-item');
892
892
  mountTo(panel, element);
893
893
  }
894
894
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gcorevideo/player",
3
- "version": "2.25.6",
3
+ "version": "2.25.7",
4
4
  "description": "Gcore JavaScript video player",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -1,19 +1,18 @@
1
1
  import { Events, UICorePlugin, template } from '@clappr/core'
2
2
  import { AudioTrack } from '@clappr/core/types/base/playback/playback.js'
3
3
  import assert from 'assert'
4
+ // import { trace } from '@gcorevideo/utils'
4
5
 
5
6
  import { CLAPPR_VERSION } from '../../build.js'
6
7
 
7
8
  import pluginHtml from '../../../assets/audio-tracks/template.ejs'
8
- import '../../../assets/audio-tracks/style.scss'
9
9
  import audioArrow from '../../../assets/icons/old/quality-arrow.svg'
10
10
  import { ZeptoResult } from '../../types.js'
11
11
  import { ExtendedEvents, MediaControl } from '../media-control/MediaControl.js'
12
- import { trace } from '@gcorevideo/utils'
13
12
 
14
13
  const VERSION: string = '2.22.4'
15
14
 
16
- const T = 'plugins.audiotracks'
15
+ // const T = 'plugins.audiotracks'
17
16
 
18
17
  /**
19
18
  * `PLUGIN` that makes possible to switch audio tracks via the media control UI.
@@ -28,6 +27,8 @@ const T = 'plugins.audiotracks'
28
27
  export class AudioTracks extends UICorePlugin {
29
28
  private currentTrack: AudioTrack | null = null
30
29
 
30
+ private open = false
31
+
31
32
  private tracks: AudioTrack[] = []
32
33
 
33
34
  /**
@@ -58,7 +59,7 @@ export class AudioTracks extends UICorePlugin {
58
59
  */
59
60
  override get attributes() {
60
61
  return {
61
- class: 'media-control-audiotracks',
62
+ class: 'media-control-audiotracks media-control-dd__wrap',
62
63
  }
63
64
  }
64
65
 
@@ -67,8 +68,8 @@ export class AudioTracks extends UICorePlugin {
67
68
  */
68
69
  override get events() {
69
70
  return {
70
- 'click [data-audiotracks-select]': 'onTrackSelect',
71
- 'click #audiotracks-button': 'toggleMenu',
71
+ 'click #gplayer-audiotracks-menu [data-item]': 'onTrackSelect',
72
+ 'click #gplayer-audiotracks-button': 'toggleMenu',
72
73
  }
73
74
  }
74
75
 
@@ -87,15 +88,21 @@ export class AudioTracks extends UICorePlugin {
87
88
  private onCoreReady() {
88
89
  const mediaControl = this.core.getPlugin('media_control')
89
90
  assert(mediaControl, 'media_control plugin is required')
91
+
90
92
  this.listenTo(mediaControl, Events.MEDIACONTROL_RENDERED, () => {
91
- mediaControl.slot('audiotracks', this.$el)
93
+ this.mount()
92
94
  })
95
+ // TODO when tracks change, re-render and re-attach
93
96
  this.listenTo(mediaControl, Events.MEDIACONTROL_HIDE, this.hideMenu)
94
- this.listenTo(mediaControl, ExtendedEvents.MEDIACONTROL_MENU_COLLAPSE, (from: string) => {
95
- if (from !== this.name) {
96
- this.hideMenu()
97
- }
98
- })
97
+ this.listenTo(
98
+ mediaControl,
99
+ ExtendedEvents.MEDIACONTROL_MENU_COLLAPSE,
100
+ (from: string) => {
101
+ if (from !== this.name) {
102
+ this.hideMenu()
103
+ }
104
+ },
105
+ )
99
106
  }
100
107
 
101
108
  private onActiveContainerChanged() {
@@ -108,6 +115,7 @@ export class AudioTracks extends UICorePlugin {
108
115
  tracks.find((track) => track.kind === 'main') ?? null // TODO test
109
116
  this.tracks = tracks
110
117
  this.render()
118
+ this.mount()
111
119
  },
112
120
  )
113
121
  this.listenTo(
@@ -120,6 +128,10 @@ export class AudioTracks extends UICorePlugin {
120
128
  this.updateText()
121
129
  },
122
130
  )
131
+ // TODO test
132
+ this.listenTo(this.core.activeContainer, Events.CONTAINER_CLICK, () => {
133
+ this.hideMenu()
134
+ })
123
135
  }
124
136
 
125
137
  private shouldRender() {
@@ -132,18 +144,15 @@ export class AudioTracks extends UICorePlugin {
132
144
  * @internal
133
145
  */
134
146
  override render() {
135
- if (!this.shouldRender()) {
136
- return this
137
- }
138
-
139
147
  this.$el.html(
140
148
  AudioTracks.template({
141
- tracks: this.tracks,
149
+ tracks: this.tracks ?? [],
142
150
  title: this.getTitle(),
143
151
  icon: audioArrow,
144
152
  current: this.currentTrack?.id,
145
153
  }),
146
154
  )
155
+ this.$el.find('#gplayer-audiotracks-menu').hide()
147
156
  this.updateText()
148
157
  this.highlightCurrentTrack()
149
158
 
@@ -151,7 +160,7 @@ export class AudioTracks extends UICorePlugin {
151
160
  }
152
161
 
153
162
  private onTrackSelect(event: MouseEvent) {
154
- const id = (event.currentTarget as HTMLElement)?.dataset?.audiotracksSelect
163
+ const id = (event.currentTarget as HTMLElement)?.dataset?.item
155
164
  if (id) {
156
165
  this.selectAudioTrack(id)
157
166
  }
@@ -167,31 +176,40 @@ export class AudioTracks extends UICorePlugin {
167
176
  }
168
177
 
169
178
  private hideMenu() {
170
- trace(`${T} hideMenu`)
171
- this.$el.find('#audiotracks-select').addClass('hidden')
172
- this.$el.find('#audiotracks-button').attr('aria-expanded', 'false')
179
+ this.open = false
180
+ this.$el.find('#gplayer-audiotracks-menu').hide()
181
+ this.$el.find('#gplayer-audiotracks-button').attr('aria-expanded', 'false')
173
182
  }
174
183
 
175
184
  private toggleMenu() {
176
- this.core.getPlugin('media_control').trigger(ExtendedEvents.MEDIACONTROL_MENU_COLLAPSE, this.name)
177
- this.$el.find('#audiotracks-select').toggleClass('hidden') // TODO use plain CSS display: none
178
- const open = !this.$el.find('#audiotracks-select').hasClass('hidden') // TODO hold state
179
- this.$el.find('#audiotracks-button').attr('aria-expanded', open)
185
+ this.open = !this.open
186
+
187
+ this.core
188
+ .getPlugin('media_control')
189
+ .trigger(ExtendedEvents.MEDIACONTROL_MENU_COLLAPSE, this.name)
190
+ if (this.open) {
191
+ this.$el.find('#gplayer-audiotracks-menu').show()
192
+ } else {
193
+ this.$el.find('#gplayer-audiotracks-menu').hide()
194
+ }
195
+ this.$el
196
+ .find('#gplayer-audiotracks-button')
197
+ .attr('aria-expanded', this.open)
180
198
  }
181
199
 
182
200
  private buttonElement(): ZeptoResult {
183
- return this.$('button')
201
+ return this.$('#gplayer-audiotracks-button')
184
202
  }
185
203
 
186
204
  private buttonElementText(): ZeptoResult {
187
- return this.$('button .audio-text')
205
+ return this.$el.find('#gplayer-audiotracks-button-text')
188
206
  }
189
207
 
190
208
  private trackElement(id?: string): ZeptoResult {
191
209
  return (
192
210
  this.$(
193
- '#audiotracks-select a' +
194
- (id !== undefined ? `[data-audiotracks-select="${id}"]` : ''),
211
+ '#gplayer-audiotracks-menu a' +
212
+ (id !== undefined ? `[data-item="${id}"]` : ''),
195
213
  ) as ZeptoResult
196
214
  ).parent()
197
215
  }
@@ -229,4 +247,10 @@ export class AudioTracks extends UICorePlugin {
229
247
  .attr('aria-checked', 'true')
230
248
  }
231
249
  }
250
+
251
+ private mount() {
252
+ if (this.shouldRender()) {
253
+ this.core.getPlugin('media_control')?.slot('audiotracks', this.$el)
254
+ }
255
+ }
232
256
  }
@@ -1,5 +1,6 @@
1
1
  import { beforeEach, describe, expect, it, vi } from 'vitest'
2
2
  import { Events } from '@clappr/core'
3
+
3
4
  import { ExtendedEvents } from '../../media-control/MediaControl'
4
5
  import { AudioTracks } from '../AudioTracks'
5
6
 
@@ -29,54 +30,51 @@ describe('AudioTracks', () => {
29
30
  core.emit(Events.CORE_READY)
30
31
  core.emit(Events.CORE_ACTIVE_CONTAINER_CHANGED, core.activeContainer)
31
32
  })
32
- describe('before media control is rendererd', () => {
33
- beforeEach(() => {
34
- emitTracksAvailable(core, TRACKS)
33
+ describe('basically', () => {
34
+ it('should render button', () => {
35
+ expect(audioTracks.$el.find('#gplayer-audiotracks-button').length).toBe(1)
35
36
  })
36
- it('should not attach to the media control', () => {
37
- expect(mediaControl.slot).not.toHaveBeenCalledWith(
38
- 'audiotracks',
39
- expect.anything(),
40
- )
37
+ it('should render menu hidden', () => {
38
+ expect(audioTracks.$el.find('#gplayer-audiotracks-menu').css('display')).toBe('none')
41
39
  })
42
40
  })
43
- describe('when media control is rendered', () => {
44
- beforeEach(() => {
45
- mediaControl.trigger(Events.MEDIACONTROL_RENDERED)
46
- })
47
- it('should attach to the media control', () => {
48
- expect(mediaControl.slot).toHaveBeenCalledWith(
41
+ describe('until audio tracks are available', () => {
42
+ it('should not mount', () => {
43
+ expect(mediaControl.slot).not.toHaveBeenCalledWith(
49
44
  'audiotracks',
50
- audioTracks.$el,
45
+ expect.anything(),
51
46
  )
52
47
  })
53
48
  })
54
- describe('given that audio tracks are available', () => {
49
+ describe('when audio tracks are available', () => {
55
50
  beforeEach(() => {
56
51
  emitTracksAvailable(core, TRACKS)
57
52
  })
58
- it('should render button', () => {
59
- expect(audioTracks.$el.find('#audiotracks-button').length).toBe(1)
60
- })
61
- it('should render menu hidden', () => {
53
+ it('should render menu', () => {
62
54
  expect(audioTracks.el.innerHTML).toMatchSnapshot()
63
55
  expect(
64
- audioTracks.$el.find('#audiotracks-select').hasClass('hidden'),
65
- ).toBe(true)
66
- const trackItems = audioTracks.$el.find('#audiotracks-select li')
56
+ audioTracks.$el.find('#gplayer-audiotracks-menu').css('display'),
57
+ ).toBe('none')
58
+ const trackItems = audioTracks.$el.find('#gplayer-audiotracks-menu li')
67
59
  expect(trackItems.length).toBe(2)
68
60
  expect(trackItems.eq(0).text().trim()).toBe('English')
69
61
  expect(trackItems.eq(1).text().trim()).toBe('Spanish')
70
62
  })
63
+ it('should mount', () => {
64
+ expect(mediaControl.slot).toHaveBeenCalledWith(
65
+ 'audiotracks',
66
+ audioTracks.$el,
67
+ )
68
+ })
71
69
  describe('when button is clicked', () => {
72
70
  beforeEach(() => {
73
- audioTracks.$el.find('#audiotracks-button').click()
71
+ audioTracks.$el.find('#gplayer-audiotracks-button').click()
74
72
  })
75
73
  it('should show menu', () => {
76
74
  expect(audioTracks.$el.html()).toMatchSnapshot()
77
75
  expect(
78
- audioTracks.$el.find('#audiotracks-select').hasClass('hidden'),
79
- ).toBe(false)
76
+ audioTracks.$el.find('#gplayer-audiotracks-menu').css('display'),
77
+ ).not.toBe('none')
80
78
  })
81
79
  it('should collapse all other menus', () => {
82
80
  expect(mediaControl.trigger).toHaveBeenCalledWith(
@@ -87,7 +85,7 @@ describe('AudioTracks', () => {
87
85
  describe('when audio track is selected', () => {
88
86
  beforeEach(() => {
89
87
  audioTracks.$el
90
- .find('#audiotracks-select [data-audiotracks-select="2"]')
88
+ .find('#gplayer-audiotracks-menu [data-item="2"]')
91
89
  .click()
92
90
  })
93
91
  it('should switch to the selected audio track', () => {
@@ -98,13 +96,13 @@ describe('AudioTracks', () => {
98
96
  it('should hide the menu', () => {
99
97
  expect(audioTracks.$el.html()).toMatchSnapshot()
100
98
  expect(
101
- audioTracks.$el.find('#audiotracks-select').hasClass('hidden'),
102
- ).toBe(true)
103
- expect(audioTracks.$el.find('#audiotracks-button').attr('aria-expanded')).toBe('false')
99
+ audioTracks.$el.find('#gplayer-audiotracks-menu').css('display'),
100
+ ).toBe('none')
101
+ expect(audioTracks.$el.find('#gplayer-audiotracks-button').attr('aria-expanded')).toBe('false')
104
102
  })
105
103
  it('should add changing class to the button', () => {
106
104
  expect(
107
- audioTracks.$el.find('#audiotracks-button').hasClass('changing'),
105
+ audioTracks.$el.find('#gplayer-audiotracks-button').hasClass('changing'),
108
106
  ).toBe(true)
109
107
  })
110
108
  describe('when current audio track changes', () => {
@@ -123,14 +121,14 @@ describe('AudioTracks', () => {
123
121
  it('should update button class', () => {
124
122
  expect(
125
123
  audioTracks.$el
126
- .find('#audiotracks-button')
124
+ .find('#gplayer-audiotracks-button')
127
125
  .hasClass('changing'),
128
126
  ).toBe(false)
129
127
  })
130
128
  it('should update button label', () => {
131
129
  expect(
132
130
  audioTracks.$el
133
- .find('#audiotracks-button')
131
+ .find('#gplayer-audiotracks-button')
134
132
  .text()
135
133
  .replace(/\/assets.*\.svg/g, '')
136
134
  .trim(),
@@ -138,22 +136,22 @@ describe('AudioTracks', () => {
138
136
  })
139
137
  it('should highlight the selected menu item', () => {
140
138
  const selectedItem = audioTracks.$el.find(
141
- '#audiotracks-select .current',
139
+ '#gplayer-audiotracks-menu .current',
142
140
  )
143
141
  expect(selectedItem.text().trim()).toBe('Spanish')
144
142
  expect(
145
143
  selectedItem
146
- .find('a[data-audiotracks-select]')
144
+ .find('a[data-item]')
147
145
  .hasClass('gcore-skin-active'),
148
146
  ).toBe(true)
149
147
  })
150
148
  it('should unhighlight any previously highlighted menu item', () => {
151
149
  expect(
152
- audioTracks.$el.find('#audiotracks-select li.current').length,
150
+ audioTracks.$el.find('#gplayer-audiotracks-menu li.current').length,
153
151
  ).toBe(1)
154
152
  expect(
155
153
  audioTracks.$el.find(
156
- '#audiotracks-select a.gcore-skin-active[data-audiotracks-select]',
154
+ '#gplayer-audiotracks-menu a.gcore-skin-active[data-item]',
157
155
  ).length,
158
156
  ).toBe(1)
159
157
  })
@@ -162,19 +160,36 @@ describe('AudioTracks', () => {
162
160
  })
163
161
  describe('when button is clicked twice', () => {
164
162
  beforeEach(() => {
165
- audioTracks.$el.find('#audiotracks-button').click()
166
- audioTracks.$el.find('#audiotracks-button').click()
163
+ audioTracks.$el.find('#gplayer-audiotracks-button').click()
164
+ audioTracks.$el.find('#gplayer-audiotracks-button').click()
167
165
  })
168
166
  it('should collapse the menu', () => {
169
- expect(audioTracks.$el.find('#audiotracks-select').hasClass('hidden')).toBe(true)
170
- expect(audioTracks.$el.find('#audiotracks-button').attr('aria-expanded')).toBe('false')
167
+ expect(audioTracks.$el.find('#gplayer-audiotracks-menu').css('display')).toBe('none')
168
+ expect(audioTracks.$el.find('#gplayer-audiotracks-button').attr('aria-expanded')).toBe('false')
169
+ })
170
+ })
171
+ describe('when media control is rendered', () => {
172
+ beforeEach(() => {
173
+ mediaControl.slot.mockClear()
174
+ mediaControl.trigger(Events.MEDIACONTROL_RENDERED)
175
+ })
176
+ it('should remount', () => {
177
+ expect(mediaControl.slot).toHaveBeenCalledWith(
178
+ 'audiotracks',
179
+ audioTracks.$el,
180
+ )
171
181
  })
172
182
  })
173
183
  })
174
- describe('when audio tracks are not available', () => {
175
- it('should not render the button', () => {
176
- expect(audioTracks.$el.find('#audiotracks-button').length).toBe(0)
177
- expect(audioTracks.$el.find('#audiotracks-select').length).toBe(0)
184
+ describe('when container is clicked', () => {
185
+ beforeEach(() => {
186
+ emitTracksAvailable(core, TRACKS)
187
+ audioTracks.$el.find('#gplayer-audiotracks-button').click()
188
+ core.activeContainer.emit(Events.CONTAINER_CLICK)
189
+ })
190
+ it('should hide the menu', () => {
191
+ expect(audioTracks.$el.find('#gplayer-audiotracks-menu').css('display')).toBe('none')
192
+ expect(audioTracks.$el.find('#gplayer-audiotracks-button').attr('aria-expanded')).toBe('false')
178
193
  })
179
194
  })
180
195
  })