-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Card class testing #8
Changes from 12 commits
6b60bf2
593384e
93b60e2
0ab6515
1b08108
3b5bb92
47a0a74
217ccac
374127f
93bd66a
ad041da
9b03474
5345360
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"use strict"; | ||
// require('./libs/ace/ext-modelist.js'); // Don't delete me! Needed by ace.req | ||
const Card = require('../app/Card.js'); | ||
|
||
module.exports = class CodeEditor extends Card { | ||
constructor(type) { | ||
super(type); | ||
this.type = type; | ||
this.faces = []; | ||
this.editors = []; | ||
|
||
this.content = document.createElement('div'); | ||
$(this.content).attr('class', 'codeEditor'); | ||
|
||
for (let i = 0; i < 3; i++) { | ||
this.face = document.createElement('div'); | ||
if (i == 2) | ||
this.faceEditor = document.createElement('div'); | ||
else | ||
this.faceEditor = document.createElement('textarea'); | ||
this.face.appendChild(this.faceEditor); | ||
this.faces.push(this.face); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"use strict"; | ||
const Card = require('../app/Card.js'); | ||
var Raphael = require('raphael'); | ||
|
||
module.exports = class SketchPad extends Card { | ||
constructor(type) { | ||
super(type); | ||
this.type = type; | ||
this.faces = []; | ||
this.pens = []; | ||
|
||
this.content = document.createElement('div'); | ||
$(this.content).attr('class', 'sketchEditor'); | ||
|
||
for (let i = 0; i < 3; i++) { | ||
this.face = document.createElement('div'); | ||
this.faceEditor = document.createElement('div'); | ||
this.face.appendChild(this.faceEditor); | ||
this.faces.push(this.face); | ||
} | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"use strict"; | ||
const Card = require('../app/Card.js'); | ||
|
||
module.exports = class TextEditor extends Card{ | ||
constructor(type) { | ||
super(type); | ||
this.type = type; | ||
this.faces = []; | ||
this.editors = []; | ||
|
||
this.content = document.createElement('div'); | ||
$(this.content).attr('class', 'textEditor'); | ||
|
||
for (let i = 0; i < 3; i++) { | ||
this.face = document.createElement('div'); | ||
if (i == 2) //3rd card face is metadata | ||
this.faceEditor = document.createElement('div'); | ||
else { //1st and 2nd card faces are textareas | ||
this.faceEditor = document.createElement('textarea'); | ||
this.editors.push(this.faceEditor); | ||
} | ||
|
||
this.face.appendChild(this.faceEditor); | ||
this.faces.push(this.face); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,21 @@ var Application = require('spectron').Application; | |
var electron = require('electron-prebuilt'); | ||
var assert = require('assert'); | ||
const path = require('path'); | ||
var fs = require('fs'); | ||
var Card = require('../app/Card.js'); | ||
var Canvas = require('../app/Canvas.js'); | ||
var TextEditor = require('../app/textEditor.js') | ||
var SketchPad = require('../app/sketchPad.js') | ||
var CodeEditor = require('../app/codeEditor.js') | ||
|
||
describe('cards interactions', function () { | ||
this.timeout(30000); | ||
var app; | ||
|
||
before(function () { | ||
app = new Application({ | ||
path: electron, | ||
this.jsdom = require('jsdom-global')() | ||
global.$ = global.jQuery = require('jquery'); | ||
app = new Application({ path: electron, | ||
args: [path.join(__dirname, '..', 'main.js')], | ||
}); | ||
return app.start(); | ||
|
@@ -34,6 +40,40 @@ describe('cards interactions', function () { | |
}, Error ); | ||
}); | ||
|
||
// it('correctly names a card', function () { | ||
// let card = new Card({id: 1, context: document.body, modal: false}); | ||
// return assert.equal(card.name, "My Card " + card.id); | ||
// }); | ||
|
||
// it('two cards do not have the same name', function () { | ||
// let card = new Card({id: 1, context: document.body, modal: false}); | ||
// let card2 = new Card({id: 2, context: document.body, modal: false}); | ||
// return assert.notEqual(card.name, card2.name); | ||
// }); | ||
|
||
it('document contains a card and header div', function () { | ||
let card = new Card({id: 1, context: document.body, modal: false}); | ||
let msg1 = card.card + ' document contains card div'; | ||
let msg2 = card.header + ' document contains header div' | ||
assert.notEqual(card.card, undefined, msg1); | ||
assert.notEqual(card.header, undefined, msg2); | ||
}); | ||
|
||
it('document contains namebox span', function () { | ||
let card = new Card({id: 1, context: document.body, modal: false}); | ||
assert.notEqual(card.title, undefined); | ||
}); | ||
|
||
// it('document contains close, expand, and save buttons', function () { | ||
// let card = new Card({id: 1, context: document.body, modal: false}); | ||
// let msg1 = 'document contains close button'; | ||
// let msg2 = 'document contains expand button'; | ||
// let msg3 = 'document contains save button'; | ||
// assert.notEqual(card.closeButton, undefined, msg1); | ||
// assert.notEqual(card.saveButton, undefined, msg2); | ||
// assert.notEqual(card.fullscreenButton, undefined, msg3); | ||
// }); | ||
|
||
it('Card instantiation without \'id\' parameter throws Error', function () { | ||
return assert.throws(() => { | ||
new Card({context: document.body, modal: false}); | ||
|
@@ -59,12 +99,105 @@ describe('cards interactions', function () { | |
let msg2 = card.createdBy + " == " + createdByBefore + | ||
"\n\t(createdBy should not change once Card is instantiated)"; | ||
let msg3 = card.lastInteraction + " != " + lastInteractionBefore + | ||
"\n\t(lastInteraction should update after Card#updateMetadata()" + | ||
" method is evoked)"; | ||
"\n\t(lastInteraction should update after Card#updateMetadata()" + | ||
" method is evoked)"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For lines 102-103, it is unclear why these lines are being shortened up to the same vertical alignment as line 101, which represents the starting line for the run-on content that is on lines 102-103. Especially in light of the allowance for the original style on lines 99-100 remaining the same. This change creates a discontinuity in styles. |
||
assert.equal(card.createdTimestamp, createdTimestampBefore, msg1); | ||
assert.equal(card.createdBy, createdByBefore, msg2); | ||
assert.notEqual(card.lastInteraction, lastInteractionBefore, msg3); | ||
}); | ||
|
||
// it('card dragability can be disabled', function () { | ||
// let card = new Card(); | ||
// $(card.card).data('draggable'); | ||
// if ($(card.card).draggable('disable')) | ||
// var disabled = 1; | ||
// return assert.equal(disabled, 1); | ||
// }); | ||
|
||
// it('toggleDraggable sets correct card position', function () { | ||
// let card = new Card(); | ||
// $(card).css({top: 200, left: 250}); | ||
// var topPosition = $(card).offset().top + 'px'; | ||
// var leftPosition = $(card).offset().left + 'px'; | ||
// let msg1 = 'toggleDraggable sets card top position to be: ' + topPosition + | ||
// ' but, card top position should be 200px'; | ||
// let msg2 = 'toggleDraggable sets card left position to be: ' + leftPosition + | ||
// ' but, card left position should be 250px'; | ||
// assert.equal('200px', topPosition, msg1); | ||
// assert.equal('250px', leftPosition, msg2); | ||
// }); | ||
|
||
// it('card dropability can be disabled', function () { | ||
// let card = new Card(); | ||
// $(card.card).data('droppable'); | ||
// if($(card.card).droppable('disabled'))) | ||
// var disabled = 1; | ||
// return assert.equal(disabled, 1); | ||
// }); | ||
|
||
// it('card intance has correct height and width when fullscreen mode is toggled on', function () { | ||
// let card = new Card(); | ||
// card.toggleButton.trigger('click'); | ||
// var curHeight = card.offsetHeight; | ||
// var curWdith = card.offsetWidth; | ||
// var idealHeight = document.offsetHeight; | ||
// var idealWidth = document.offsetWidth; | ||
// let msg1 = 'current height of card is: ' + curHeight + ' but, ideal height is: ' + idealHeight; | ||
// let msg2 = 'current widtht of card is: ' + curWidth + ' but, ideal width is: ' + idealWidth; | ||
// assert.equal(idealHeight, curHeight); | ||
// assert.equal(idealWidth, curWidth); | ||
// }); | ||
|
||
it('creates a texteditor card instance', function () { | ||
let textEditor = new TextEditor({id: 1, context: document.body, modal: false}); | ||
return assert.equal(textEditor.constructor.name, 'TextEditor'); | ||
}); | ||
|
||
it('texteditor contains three faces', function () { | ||
let textEditor = new TextEditor({id: 1, context: document.body, modal: false}); | ||
return assert.equal(textEditor.faces.length, 3); | ||
}); | ||
|
||
it('texteditor contains two \'editor\' faces', function () { | ||
let textEditor = new TextEditor({id: 1, context: document.body, modal: false}); | ||
return assert.equal(textEditor.editors.length, 2); | ||
}); | ||
|
||
it('creates a sketchpad card instance', function () { | ||
let sketchPad = new SketchPad({id: 1, context: document.body, modal: false}); | ||
return assert.equal(sketchPad.constructor.name, 'SketchPad') | ||
}); | ||
|
||
it('sketchpad contains three faces', function () { | ||
let sketchPad = new SketchPad({id: 1, context: document.body, modal: false}); | ||
return assert.equal(sketchPad.faces.length, 3); | ||
}); | ||
|
||
it('sketchpad has sketch pen buttons', function () { | ||
let sketchPad = new SketchPad({id: 1, context: document.body, modal: false}); | ||
assert.notEqual(sketchPad.pens, undefined); | ||
}); | ||
|
||
// it('sketchpad has 4 sketch pens', function () { | ||
// let sketchPad = new SketchPad({id: 1, context: document.body, modal: false}); | ||
// return assert.equal(sketchPad.pens.length, 4); | ||
// }); | ||
|
||
// it('sketchpad has eraser button', function () { | ||
// let sketchPad = new SketchPad({id: 1, context: document.body, modal: false}); | ||
// return assert.notEqual(sketchPad.eraser, undefined); | ||
// }); | ||
|
||
it('creates a codeEditors card instance', function () { | ||
let codeEditor = new CodeEditor({id: 1, context: document.body, modal: false}); | ||
return assert.equal(codeEditor.constructor.name, 'CodeEditor') | ||
}); | ||
|
||
it('codeeditor contains three faces', function () { | ||
let codeEditor = new CodeEditor({id: 1, context: document.body, modal: false}); | ||
return assert.equal(codeEditor.faces.length, 3); | ||
}); | ||
|
||
}); | ||
|
||
function wait(ms){ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For line 20, there isn't really a good reason to shorten the
path:
field onto the same line as thenew Application
declaration; this change adds clutter.