mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2026-03-02 18:23:24 +01:00
- Convert Backbone.Model to ES6 classes with get/set methods - Command model in commandModel.js - Error classes in errors.js - Convert Backbone.Collection to ES6 classes - CommitCollection, CommandCollection, BranchCollection, TagCollection - CommandBuffer with event support - Convert Backbone.View to ES6 classes - All view classes in views/*.js - Visual classes in visuals/*.js - Add custom EventEmitter to replace Backbone.Events - New eventEmitter.js with on/off/trigger/once/listenTo - Fix context binding: pass 'this' as third arg to on() - Fix off() filter logic for proper listener removal - Fix event context binding in Level class - Events bound with explicit context to access this.mainVis - Remove unnecessary bypass checks in minimizeGoal/resizeGoal/showGoal - Add comprehensive tests - eventEmitter.spec.js: 16 tests for event system - collections.spec.js: tests for converted collections - commandModel.spec.js: tests for Command class - errors.spec.js: tests for error classes
99 lines
2.9 KiB
JavaScript
99 lines
2.9 KiB
JavaScript
var errors = require('../src/js/util/errors');
|
|
|
|
describe('Error Models', function() {
|
|
describe('GitError', function() {
|
|
it('should store and retrieve msg', function() {
|
|
var err = new errors.GitError({msg: 'test message'});
|
|
expect(err.getMsg()).toBe('test message');
|
|
});
|
|
|
|
it('should have correct type', function() {
|
|
var err = new errors.GitError({msg: 'test'});
|
|
expect(err.get('type')).toBe('Git Error');
|
|
});
|
|
|
|
it('should convert to string', function() {
|
|
var err = new errors.GitError({msg: 'oops'});
|
|
expect(err.toString()).toBe('Git Error: oops');
|
|
});
|
|
|
|
it('should be instanceof GitError', function() {
|
|
var err = new errors.GitError({msg: 'test'});
|
|
expect(err instanceof errors.GitError).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('Warning', function() {
|
|
it('should store and retrieve msg', function() {
|
|
var err = new errors.Warning({msg: 'warning message'});
|
|
expect(err.getMsg()).toBe('warning message');
|
|
});
|
|
|
|
it('should have correct type', function() {
|
|
var err = new errors.Warning({msg: 'test'});
|
|
expect(err.get('type')).toBe('Warning');
|
|
});
|
|
});
|
|
|
|
describe('CommandProcessError', function() {
|
|
it('should store and retrieve msg', function() {
|
|
var err = new errors.CommandProcessError({msg: 'process error'});
|
|
expect(err.getMsg()).toBe('process error');
|
|
});
|
|
|
|
it('should have correct type', function() {
|
|
var err = new errors.CommandProcessError({msg: 'test'});
|
|
expect(err.get('type')).toBe('Command Process Error');
|
|
});
|
|
});
|
|
|
|
describe('CommandResult', function() {
|
|
it('should store and retrieve msg', function() {
|
|
var err = new errors.CommandResult({msg: 'result'});
|
|
expect(err.getMsg()).toBe('result');
|
|
});
|
|
|
|
it('should have correct type', function() {
|
|
var err = new errors.CommandResult({msg: 'test'});
|
|
expect(err.get('type')).toBe('Command Result');
|
|
});
|
|
});
|
|
|
|
describe('filterError', function() {
|
|
it('should not throw for GitError', function() {
|
|
var err = new errors.GitError({msg: 'test'});
|
|
expect(function() {
|
|
errors.filterError(err);
|
|
}).not.toThrow();
|
|
});
|
|
|
|
it('should not throw for Warning', function() {
|
|
var err = new errors.Warning({msg: 'test'});
|
|
expect(function() {
|
|
errors.filterError(err);
|
|
}).not.toThrow();
|
|
});
|
|
|
|
it('should not throw for CommandProcessError', function() {
|
|
var err = new errors.CommandProcessError({msg: 'test'});
|
|
expect(function() {
|
|
errors.filterError(err);
|
|
}).not.toThrow();
|
|
});
|
|
|
|
it('should not throw for CommandResult', function() {
|
|
var err = new errors.CommandResult({msg: 'test'});
|
|
expect(function() {
|
|
errors.filterError(err);
|
|
}).not.toThrow();
|
|
});
|
|
|
|
it('should throw for unknown errors', function() {
|
|
var err = new Error('unknown');
|
|
expect(function() {
|
|
errors.filterError(err);
|
|
}).toThrow();
|
|
});
|
|
});
|
|
});
|