Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
captions stat get and set in viewer.
  • Loading branch information
processprocess committed Apr 4, 2022
commit c3524685e994af3777c9156942c51a7964489bb8
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ let GetStateConfigurationDef;

/** @enum {!GetStateConfigurationDef} */
const GET_STATE_CONFIGURATIONS = {
'CAPTIONS_STATE': {
dataSource: DataSources.STORE_SERVICE,
property: StateProperty.CAPTIONS_STATE,
},
'CURRENT_PAGE_ID': {
dataSource: DataSources.STORE_SERVICE,
property: StateProperty.CURRENT_PAGE_ID,
Expand Down Expand Up @@ -57,6 +61,10 @@ let SetStateConfigurationDef;

/** @enum {!SetStateConfigurationDef} */
const SET_STATE_CONFIGURATIONS = {
'CAPTIONS_STATE': {
action: Action.TOGGLE_CAPTIONS,
isValueValid: (value) => typeof value === 'boolean',
},
'MUTED_STATE': {
action: Action.TOGGLE_MUTED,
isValueValid: (value) => typeof value === 'boolean',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ describes.fakeWin('amp-story-viewer-messaging-handler', {}, (env) => {
value: 0.5,
});
});

it('should return the CAPTIONS_STATE', async () => {
const response = await fakeViewerService.receiveMessage(
'getDocumentState',
{state: 'CAPTIONS_STATE'}
);
expect(response).to.deep.equal({
state: 'CAPTIONS_STATE',
value: storeService.get(StateProperty.CAPTIONS_STATE),
});
});
});

describe('onDocumentState', () => {
Expand Down Expand Up @@ -202,13 +213,22 @@ describes.fakeWin('amp-story-viewer-messaging-handler', {}, (env) => {
}
});

it('should set a state', async () => {
it('should set MUTED_STATE', async () => {
storeService.dispatch(Action.TOGGLE_MUTED, false);
await fakeViewerService.receiveMessage('setDocumentState', {
state: 'MUTED_STATE',
value: true,
});
expect(storeService.get(StateProperty.MUTED_STATE)).to.be.true;
});

it('should set CAPTIONS_STATE', async () => {
storeService.dispatch(Action.TOGGLE_CAPTIONS, false);
await fakeViewerService.receiveMessage('setDocumentState', {
state: 'CAPTIONS_STATE',
value: true,
});
expect(storeService.get(StateProperty.MUTED_STATE)).to.be.true;
});
});
});