Skip to content

Commit

Permalink
Add a test to catch missing demo messages
Browse files Browse the repository at this point in the history
PR #2330 introduced a new message without a definition for it.  This
test would have caught the mistake in advance.

Change-Id: I1a7b0fa2483b791b6b16405e55af84a49d100c83
  • Loading branch information
joeyparrish committed Jan 8, 2020
1 parent 68832a1 commit 18208f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ module.exports = (config) => {
{pattern: 'test/test/assets/*', included: false},
{pattern: 'dist/shaka-player.ui.js', included: false},
{pattern: 'dist/locales.js', included: false},
{pattern: 'demo/locales/en.json', included: false},
{pattern: 'demo/locales/source.json', included: false},
{pattern: 'node_modules/**/*.js', included: false},
],

Expand Down
12 changes: 12 additions & 0 deletions test/demo/demo_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ describe('Demo', () => {
await shakaDemoMain.cleanup();
});

it('has all messages defined', async () => {
const englishResponse = await fetch('/base/demo/locales/en.json');
const englishMessages = await englishResponse.json();
const sourceResponse = await fetch('/base/demo/locales/source.json');
const sourceMessages = await sourceResponse.json();

for (const id of Object.values(shakaDemo.MessageIds)) {
expect(englishMessages[id]).withContext(`id=${id}, English`).toBeTruthy();
expect(sourceMessages[id]).withContext(`id=${id}, source`).toBeTruthy();
}
});

describe('config', () => {
it('does not have entries for invalid config options', () => {
// We determine whether a config option has been made or not by looking at
Expand Down

0 comments on commit 18208f8

Please sign in to comment.