Closed JanKoehnlein closed 7 years ago
An exemplary test for commands could look like
// setup the GModel
const model = new GGraph({
id: 'graph',
type: 'graph',
shapes: [{
id: 'node0', type: 'circle', selected=true, x: 100, y: 100
},{
id: 'node1', type: 'circle', x: 100, y: 100
},
]
});
// create the command
const cmd = new SelectionCommand({
selected = [ 'node1' ],
deselected = ['node0']
})
// execute command
const newModel = cmd.execute(model)
// check result
const nodes = newModel.getChildren()
// assertions, e.g. using chai should style
const node0 = newModel.index.getById('node0')
node0.selected.should.be.false
nodes.indexOf(node0).should.equal(1)
const node1 = newModel.index.getById('node1')
node1.selected.should.be.true
nodes.indexOf(node1).should.equal(0)
// test undo
...
// test redo
...
Theia is going to use mocha, chai and karma.
We have set up various kinds of tests:
I think, that's enough to close this issue.
Hook up an appropriate testing framework (mocha, jest, or similar) with npm and write some basic tests.