-
Notifications
You must be signed in to change notification settings - Fork 482
/
ccTest.js
40 lines (36 loc) · 1.19 KB
/
ccTest.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
import {expect} from '../../../util/configuredChai';
import sinon from 'sinon';
import {singleton as studioApp} from '@cdo/apps/StudioApp';
import {executeUserCode} from '@cdo/apps/craft/code-connection/craft';
describe('Code Connection extension', () => {
it('move forward block to verify single key-value parsing', done => {
sinon.stub(studioApp(), 'highlight');
const mockClient = {
async_command: command => {
expect(command).to.eql('move?direction=forward');
done();
}
};
executeUserCode(mockClient, 'move(0, "forward")');
});
it('place forward block to verify multiple key-value parsing', done => {
const mockClient = {
async_command: command => {
expect(command).to.eql('place?slotNum=0&direction=forward');
done();
}
};
executeUserCode(mockClient, 'place(0, "0", "forward")');
});
it('give block to verify item type', done => {
const mockClient = {
async_command: command => {
expect(command).to.eql(
'give?player=steve&itemName=stone&data=1&amount=2'
);
done();
}
};
executeUserCode(mockClient, `give(0, "steve", item(0, "stone", "1"), "2")`);
});
});