-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Reconnect improvements (#5) * fix: Remove outfile from test command * fix: Add missing paths to .npmignore * fix: Replace dynamic `convertToInworldPacket` to static method * feat: Allow users to save session and scene in externally provided storage * feat: Use one getter/setter to save session * fix: Remove not actual examples README (docs should be used instead) * feat: Improve test coverage * feat: Allow to serialize/deserialize session * feat: Mark some methods as depricated * fix: Allow to return any for GetterSetter * feat: Add additional eslint rules * Add phoneme and silence event support (#9) * feat: Add phonemes support * feat: Add silence event support * chore: Release 1.2.0
- Loading branch information
1 parent
f3c399b
commit 3427cb4
Showing
27 changed files
with
760 additions
and
473 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { v4 } from 'uuid'; | ||
|
||
import { LoadSceneResponse } from '../../proto/world-engine_pb'; | ||
import { Character } from '../../src/entities/character.entity'; | ||
import { Scene } from '../../src/entities/scene.entity'; | ||
import { createAgent, createCharacter } from '../helpers'; | ||
|
||
let key: string; | ||
let characters: Array<Character> = []; | ||
let scene: Scene; | ||
let json: string; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
|
||
key = v4(); | ||
characters = [createCharacter(), createCharacter()]; | ||
scene = new Scene({ | ||
characters, | ||
key, | ||
}); | ||
json = JSON.stringify(scene); | ||
}); | ||
|
||
test('should return scene fields', () => { | ||
expect(scene.characters).toEqual(characters); | ||
expect(scene.key).toEqual(key); | ||
}); | ||
|
||
test('should serialize', () => { | ||
expect(Scene.serialize(scene)).toEqual(json); | ||
}); | ||
|
||
test('should deserialize', () => { | ||
const result = Scene.deserialize(json); | ||
|
||
expect(result.key).toEqual(scene.key); | ||
expect(result.characters).toEqual(scene.characters); | ||
}); | ||
|
||
test('should convert proto to scene', () => { | ||
const agents = [createAgent(), createAgent(false)]; | ||
const proto = new LoadSceneResponse().setAgentsList(agents).setKey(key); | ||
const scene = Scene.fromProto(proto); | ||
|
||
expect(scene.key).toEqual(key); | ||
expect(scene.characters[0].id).toEqual(agents[0].getAgentId()); | ||
expect(scene.characters[1].id).toEqual(agents[1].getAgentId()); | ||
expect(scene.characters[1].assets.avatarImg).toEqual(undefined); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { v4 } from 'uuid'; | ||
|
||
import { Scene } from '../../src/entities/scene.entity'; | ||
import { Session } from '../../src/entities/session.entity'; | ||
import { createCharacter, sessionToken } from '../helpers'; | ||
|
||
let scene: Scene = { | ||
key: v4(), | ||
characters: [createCharacter(), createCharacter()], | ||
}; | ||
let session: Session; | ||
let json: string; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
|
||
session = new Session({ | ||
scene, | ||
sessionToken, | ||
}); | ||
json = JSON.stringify(session); | ||
}); | ||
|
||
test('should return session fields', () => { | ||
expect(session.scene).toEqual(scene); | ||
expect(session.sessionToken).toEqual(sessionToken); | ||
}); | ||
|
||
test('should serialize', () => { | ||
expect(Session.serialize(session)).toEqual(json); | ||
}); | ||
|
||
test('should deserialize', () => { | ||
const result = Session.deserialize(json); | ||
|
||
expect(result.scene).toEqual(session.scene); | ||
expect(result.sessionToken).toEqual(session.sessionToken); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.