Add UserData ioDevice for setting and getting username from blocks
This commit is contained in:
1 parent
378fd672fc
commit
6d4c6df692
5 files changed
+56
-4
No files matched your search
@@ -3,6 +3,7 @@ const Sensing = require('../../src/blocks/scratch3_sensing');
|
||||
const Runtime = require('../../src/engine/runtime');
|
||||
const Sprite = require('../../src/sprites/sprite');
|
||||
const RenderedTarget = require('../../src/sprites/rendered-target');
|
||||
const BlockUtility = require('../../src/engine/block-utility');
|
||||
|
||||
test('getPrimitives', t => {
|
||||
const rt = new Runtime();
|
||||
@@ -147,7 +148,8 @@ test('loud? boolean', t => {
|
||||
test('username block', t => {
|
||||
const rt = new Runtime();
|
||||
const sensing = new Sensing(rt);
|
||||
const util = new BlockUtility(rt.sequencer);
|
||||
|
||||
t.equal(sensing.getUsername(), '');
|
||||
t.equal(sensing.getUsername({}, util), '');
|
||||
t.end();
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
const test = require('tap').test;
|
||||
const UserData = require('../../src/io/userData');
|
||||
|
||||
test('spec', t => {
|
||||
const userData = new UserData();
|
||||
|
||||
t.type(userData, 'object');
|
||||
t.type(userData.postData, 'function');
|
||||
t.type(userData.getUsername, 'function');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('getUsername returns empty string initially', t => {
|
||||
const userData = new UserData();
|
||||
|
||||
t.strictEquals(userData.getUsername(), '');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('postData sets the username', t => {
|
||||
const userData = new UserData();
|
||||
userData.postData({username: 'TEST'});
|
||||
t.strictEquals(userData.getUsername(), 'TEST');
|
||||
t.end();
|
||||
});
|
||||
Reference in new issue
Block a user