Files
cocos4/tests/assets/test-audioSource.js
T
pandamicro 1380e46c34 Unittest (#4973)
* unit test for ts

* Fix ts-jest warnings

* Remove puppeteer for now

* fix physics define and jest config for windows

* Replace Node ref with INode ref

* Fix ci issue

* Fix

* tweak

* tweak

* Fix vscode launcher

* now physics framework export all physics component (#28)

* tweaks
2019-07-25 17:15:20 +08:00

36 lines
1.1 KiB
JavaScript

if (!isPhantomJS) {
var libPath = assetDir + '/library';
largeModule('AudioScource', {
setup: function () {
_resetGame();
AssetLibrary.init({libraryPath: libPath});
}
});
var AUDIO_UUID = '1258a1';
asyncTest('basic test', function () {
AssetLibrary.loadAsset(AUDIO_UUID, function (err, clip) {
var node = new cc.Node();
cc.director.getScene().addChild(node);
var audioSource = node.addComponent(cc.AudioSource);
audioSource.clip = clip;
audioSource.play();
strictEqual(audioSource.isPlaying, true, 'audio scource play state true after play');
audioSource.volume = 0.5;
strictEqual(audioSource.audio._volume, 0.5, 'audio scource volume after play');
audioSource.loop = true;
strictEqual(audioSource.audio._loop, true, 'audio scource loop after play');
audioSource.mute = true;
strictEqual(audioSource.audio._volume, 0, 'audio scource volume after mute');
start();
});
});
}