Skip to content

Commit

Permalink
test: speech synthesis instances
Browse files Browse the repository at this point in the history
  • Loading branch information
janantala committed May 22, 2014
1 parent c62ce90 commit e93ded7
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions test/unit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,28 +88,62 @@ describe('unit specs', function() {
expect(window.nativeSpeechSynthesisSupport).toBeDefined();
});

it('should be object', function() {
it('should be function', function() {
expect(typeof window.nativeSpeechSynthesisSupport).toBe('function');
});

it('should be boolean', function() {
expect(typeof window.nativeSpeechSynthesisSupport()).toBe('boolean');
});
});

describe('getSpeechSynthesis', function() {
it('should be defined', function() {
expect(window.getSpeechSynthesis).toBeDefined();
});

it('should be object', function() {
it('should be function', function() {
expect(typeof window.getSpeechSynthesis).toBe('function');
});

it('should return polyfill if there is no native support', function() {
if (!window.nativeSpeechSynthesisSupport()){
expect(window.getSpeechSynthesis().isPolyfill).toBe(true);
}
});

it('should return native object if available', function() {
if (window.nativeSpeechSynthesisSupport()){
expect(window.getSpeechSynthesis().isPolyfill).toBeUndefined();
}
});
});

describe('getSpeechSynthesisUtterance', function() {
it('should be defined', function() {
expect(window.getSpeechSynthesisUtterance).toBeDefined();
});

it('should be object', function() {
it('should be function', function() {
expect(typeof window.getSpeechSynthesisUtterance).toBe('function');
});

it('should return polyfill if there is no native support', function() {
var fallbackSpeechSynthesisUtterance = window.getSpeechSynthesisUtterance();
var u = new fallbackSpeechSynthesisUtterance('Hello there!');

if (!window.nativeSpeechSynthesisSupport()){
expect(u.isPolyfill).toBe(true);
}
});

it('should return native object if available', function() {
var fallbackSpeechSynthesisUtterance = window.getSpeechSynthesisUtterance();
var u = new fallbackSpeechSynthesisUtterance('Hello there!');

if (window.nativeSpeechSynthesisSupport()){
expect(u.isPolyfill).toBeUndefined();
}
});
});
});

0 comments on commit e93ded7

Please sign in to comment.