scratch-html5/test/unit/looksPrimitiveSpec.js

66 lines
2 KiB
JavaScript
Raw Normal View History

/* jasmine specs for primitives/LooksPrims.js go here */
describe ('LooksPrims', function() {
2014-03-08 02:46:59 -05:00
var looksPrims, targetSpriteMock;
beforeEach(function() {
looksPrims = LooksPrims;
2014-03-08 02:46:59 -05:00
targetSpriteMock = targetMock();
});
2014-03-08 02:46:59 -05:00
describe('showBubble for Say', function(){
var sayBlock;
beforeEach(function() {
sayBlock = {'args': ['what to say']};
interp = interpreterMock({'targetSprite': targetSpriteMock }, {'arg': sayBlock});
});
2014-03-08 02:46:59 -05:00
it('should call the showBubble method on the targetedSprite', function() {
spyOn(targetSpriteMock, "showBubble");
showBubble(sayBlock, "say");
expect(targetSpriteMock.showBubble).toHaveBeenCalled;
});
});
2014-03-08 02:46:59 -05:00
describe('showBubble for Think', function(){
var thinkBlock;
beforeEach(function() {
thinkBlock = {'args': ['what to think']};
interp = interpreterMock({'targetSprite': targetSpriteMock }, {'arg': thinkBlock});
});
it('should call the showBubble method on the targetedSprite', function() {
spyOn(targetSpriteMock, "showBubble");
showBubble(thinkBlock, "think");
expect(targetSpriteMock.showBubble).toHaveBeenCalled;
});
});
describe('showBubble for Ask', function(){
var askBlock;
beforeEach(function() {
askBlock = {'args': 'what to ask'};
interp = interpreterMock({'targetSprite': targetSpriteMock }, {'arg': askBlock});
});
it('should call the showBubble method on the targetedSprite', function() {
spyOn(targetSpriteMock, "showBubble");
spyOn(targetSpriteMock, "showAsk");
looksPrims.prototype.primDoAsk(askBlock);
expect(targetSpriteMock.showBubble).toHaveBeenCalled;
expect(targetSpriteMock.showAsk).toHaveBeenCalled;
});
});
describe('primAnswer', function(){
beforeEach(function() {
interp = interpreterMock({'targetSprite': targetSpriteMock });
});
it('should return the answer variable from the targetedSprite', function() {
expect(looksPrims.prototype.primAnswer()).toBe(22);
});
});
});