import {Injectable} from 'angular2/core';
@Injectable()
export class MyService {
var snd;
constructor() {
this.snd = new Audio('Assets/sound.wav');
}
simpleFunction() {
return true;
}
}
import {describe, expect, it} from 'angular2/testing';
import {Component} from 'angular2/core';
import {MyService} from 'my.service';
export function main() {
describe('My service', () => {
var myService: MyService = new MyService();
it('should work', () => {
expect(myService.simpleFunction).toEqual(true);
});
});
}
ReferenceError: Can't find variable: Audio
if (Audio !== undefined)
import {describe, expect, it} from 'angular2/testing';
import {Component} from 'angular2/core';
import {MyService} from 'my.service';
export function main() {
describe('My service', () => {
beforeEach(() => {
if (!window.Audio) {
window.Audio = function() {
return {
play: function() {},
pause: function() {},
// ... etc
};
};
}
});
var myService: MyService = new MyService();
it('should work', () => {
expect(myService.simpleFunction).toEqual(true);
});
});
}
@Injectable()
export class MyService {
var snd;
constructor() {
this.snd = new Audio('Assets/sound.wav');
}
simpleFunction() {
return true;
}
}
import {describe, expect, it} from 'angular2/testing';
import {Component} from 'angular2/core';
import {MyService} from 'my.service';
export function main() {
describe('My service', () => {
var myService: MyService = new MyService();
it('should work', () => {
expect(myService.simpleFunction).toEqual(true);
});
});
}
ReferenceError: Can't find variable: Audio
if (Audio !== undefined)
import {describe, expect, it} from 'angular2/testing';
import {Component} from 'angular2/core';
import {MyService} from 'my.service';
export function main() {
describe('My service', () => {
beforeEach(() => {
if (!window.Audio) {
window.Audio = function() {
return {
play: function() {},
pause: function() {},
// ... etc
};
};
}
});
var myService: MyService = new MyService();
it('should work', () => {
expect(myService.simpleFunction).toEqual(true);
});
});
}