added ability to revert (#21)
This commit is contained in:
@@ -3,15 +3,44 @@ import { expect } from 'chai';
|
||||
import { Script } from '@/domain/Script';
|
||||
|
||||
describe('Script', () => {
|
||||
|
||||
it('cannot construct with duplicate lines', () => {
|
||||
// arrange
|
||||
const code = 'duplicate\nduplicate\ntest\nduplicate';
|
||||
|
||||
// act
|
||||
function construct() { return new Script('ScriptName', code, [], true); }
|
||||
|
||||
// assert
|
||||
expect(construct).to.throw();
|
||||
describe('ctor', () => {
|
||||
describe('code', () => {
|
||||
it('cannot construct with duplicate lines', () => {
|
||||
const code = 'duplicate\nduplicate\ntest\nduplicate';
|
||||
expect(() => createWithCode(code)).to.throw();
|
||||
});
|
||||
it('cannot construct with empty lines', () => {
|
||||
const code = 'duplicate\n\n\ntest\nduplicate';
|
||||
expect(() => createWithCode(code)).to.throw();
|
||||
});
|
||||
});
|
||||
describe('revertCode', () => {
|
||||
it('cannot construct with duplicate lines', () => {
|
||||
const code = 'duplicate\nduplicate\ntest\nduplicate';
|
||||
expect(() => createWithCode('REM', code)).to.throw();
|
||||
});
|
||||
it('cannot construct with empty lines', () => {
|
||||
const code = 'duplicate\n\n\ntest\nduplicate';
|
||||
expect(() => createWithCode('REM', code)).to.throw();
|
||||
});
|
||||
it('cannot construct with when same as code', () => {
|
||||
const code = 'REM';
|
||||
expect(() => createWithCode(code, code)).to.throw();
|
||||
});
|
||||
});
|
||||
describe('canRevert', () => {
|
||||
it('returns false without revert code', () => {
|
||||
const sut = createWithCode('code');
|
||||
expect(sut.canRevert()).to.equal(false);
|
||||
});
|
||||
it('returns true with revert code', () => {
|
||||
const sut = createWithCode('code', 'non empty revert code');
|
||||
expect(sut.canRevert()).to.equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function createWithCode(code: string, revertCode?: string): Script {
|
||||
return new Script('name', code, revertCode, [], false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user