-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload.js
76 lines (60 loc) · 1.69 KB
/
load.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import 'mocha/mocha.js'
import { assert } from 'chai'
import Phaser from 'phaser'
const { mocha, Mocha } = window
mocha.setup('bdd')
const { describe: context, test, before, after, beforeEach, afterEach } = Mocha
context('Phaser', () => {
test('is an object', () => {
assert.isObject(Phaser)
})
test('is the required version', () => {
assert.propertyVal(Phaser, 'VERSION', '3.87')
})
})
context('load.plugin("SoundWatcherPlugin")', () => {
let game
beforeEach((done) => {
game = new Phaser.Game({
callbacks: {
postBoot: () => {
done()
}
}
})
})
afterEach((done) => {
// biome-ignore lint/performance/noDelete: deglobalize
delete window.SoundWatcherPlugin
game.events.once('destroy', () => {
game = null
done()
})
game.destroy(true)
})
test('load.plugin("SoundWatcherPlugin", url, true) adds and starts the plugin', (done) => {
const scene = game.scene.systemScene
scene.load
.plugin('SoundWatcherPlugin', 'dist/sound-watcher-plugin.umd.js', true)
.start()
scene.load.once('complete', () => {
assert.strictEqual(
scene.plugins.getClass('SoundWatcherPlugin'),
window.SoundWatcherPlugin,
'plugins.getClass("SoundWatcherPlugin") is SoundWatcherPlugin'
)
assert.isObject(
scene.plugins.getEntry('SoundWatcherPlugin'),
'plugins.getEntry("SoundWatcherPlugin") is an object'
)
assert.isTrue(
scene.plugins.isActive('SoundWatcherPlugin'),
'plugins.isActive("SoundWatcherPlugin") is true'
)
done()
})
})
})
mocha.globals(['Phaser', 'SoundWatcherPlugin'])
mocha.checkLeaks()
mocha.run()