Permalink
Browse files

Tests pass again. They could generally use an update, though

  • Loading branch information...
David Hirtle
David Hirtle committed Aug 14, 2012
1 parent 6084fd4 commit df8efcac9eee331e006f8dd735ac85c45d6ca808
Showing with 45 additions and 32 deletions.
  1. +1 −1 public/js/ProjectView.js
  2. +13 −2 tests/SpecRunner.html
  3. +31 −29 tests/spec/tracker.js
View
@@ -130,7 +130,7 @@ function ($, _, ko, timeago, tooltips, util, Issue, Notifier, UserManager, Messa
}
var input = this.$messageInput.val();
this.$messageInput.val('');
-
+
if (!input || input.length < 1) {
return;
}
View
@@ -12,12 +12,15 @@
<body>
<script type="text/javascript">
+// TODO: port over to mocha or something
+
require.config({
paths: {
- 'jquery': 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min',
+ 'jquery': '../public/js/lib/jquery-1.7.1.min',
'ko': '../public/js/lib/knockout-2.0.0.min',
- 'underscore': '../public/js/lib/underscore-1.2.2.min',
+ 'underscore': '../public/js/lib/underscore-min',
'timeago': '../public/js/lib/jquery.timeago',
+ 'tooltips': '../public/js/lib/tooltips',
'ProjectView': '../public/js/ProjectView',
'MessageList': '../public/js/MessageList',
'UserManager': '../public/js/UserManager',
@@ -26,7 +29,15 @@
'Notifier': '../public/js/Notifier',
'Issue': '../public/js/Issue',
'util': '../public/js/util',
+ 'omegaEvent': '../public/js/omegaEvent',
+ 'Message': '../public/js/Message',
+ 'TagFilter': '../public/js/TagFilter',
'error/NoSuchIssueError': '../public/js/error/NoSuchIssueError'
+ },
+ shim: {
+ 'underscore': {
+ exports: '_'
+ }
}
});
View
@@ -1,7 +1,7 @@
define([
- 'jquery', 'ProjectView', 'util'
+ 'jquery', 'ProjectView', 'util', 'omegaEvent'
],
-function ($, ProjectView, util) {
+function ($, ProjectView, util, OmegaEvent) {
describe("omega", function () {
@@ -16,51 +16,60 @@ describe("omega", function () {
emit: function () {}
};
+ // server version
+ function fakeIssue(id, description, creator) {
+ return {
+ id: id || 1,
+ description: description || 'test issue',
+ creator: creator || 'bob'
+ };
+ }
+
var tracker;
beforeEach(function () {
- tracker = new ProjectView(name, messageInput, form, messagesElement, socket);
+ tracker = new ProjectView(name, messageInput, messagesElement, socket);
tracker.userManager.current("norris");
tracker.userManager.loggedIn(true);
});
describe("message list", function () {
+ var omegaEvents = [
+ new OmegaEvent(OmegaEvent.Type.NewIssue, { issue: fakeIssue(1, 'first test') }),
+ new OmegaEvent(OmegaEvent.Type.AssignIssue, { issue: fakeIssue(), assigner: 'fred' }),
+ new OmegaEvent(OmegaEvent.Type.NewIssue, { issue: fakeIssue(), updater: 'fred' })
+ ];
+
it("shows history upon connection", function () {
- var omegaEvents = [
- { type: { name: 'openIssue' }, message: "test1" },
- { type: { name: 'updateIssue' }, message: "test2" },
- { type: { name: 'assignIssue' }, message: "test3" }
- ];
-
tracker.messageList.processHistory(omegaEvents);
expect(tracker.messageList.messages().length).toBe(3);
- expect(tracker.messageList.messages()[0].message).toEqual("test1");
+ expect(tracker.messageList.messages()[0].message).toEqual('bob created <a class="id" data-id="1" href="#1">Ω1</a>.');
});
it("shows consistent history by overwriting existing messages", function () {
tracker.messageList.messages([{msg: 'foo'}, {msg: 'bar'}]);
- var omegaEvents = [
- { type: { name: 'openIssue' }, message: "test1" },
- { type: { name: 'updateIssue' }, message: "test2" },
- { type: { name: 'assignIssue' }, message: "test3" }
- ];
-
+
tracker.messageList.processHistory(omegaEvents);
expect(tracker.messageList.messages().length).toBe(3);
- expect(tracker.messageList.messages()[0].message).toEqual("test1");
+ expect(tracker.messageList.messages()[0].message).toEqual('bob created <a class="id" data-id="1" href="#1">Ω1</a>.');
});
it("adds flavour when appropriate", function () {
- var closeEvent = { type: { name: 'closeIssue' }, message: "bob closed 3." };
- var assignEvent = { type: { name: 'assignIssue' }, message: "bob assigned 3 to jim." };
+ var closeEvent = new OmegaEvent(OmegaEvent.Type.CloseIssue, { issue: fakeIssue() });
+ closeEvent.timestamp = 123;
+
+ var assignEvent = new OmegaEvent(OmegaEvent.Type.AssignIssue, { issue: fakeIssue(), assigner: 'fred' });
+ assignEvent.timestamp = 123;
+
tracker.messageList.append(closeEvent);
tracker.messageList.append(assignEvent);
+ var flavour = /Die issues, die!/;
var closeMessage = tracker.messageList.messages()[0].message;
- expect(closeMessage.length).toBeGreaterThan(closeEvent.message.length);
+ expect(closeMessage).toMatch(flavour);
var assignMessage = tracker.messageList.messages()[1].message;
- expect(assignMessage.length).toEqual(assignEvent.message.length);
+ expect(assignMessage).not.toMatch(flavour);
});
});
@@ -111,6 +120,7 @@ describe("omega", function () {
it("can view help", function () {
messageInput.val = function () { return "/help"; };
+ messageInput.focus = function () {};
tracker.handleInput();
expect(tracker.helpOpen()).toEqual(true);
@@ -132,14 +142,6 @@ describe("omega", function () {
expect(socket.emit).toHaveBeenCalledWith('user message', ':)');
});
- it("can reset", function () {
- messageInput.val = function () { return "/reset"; };
-
- spyOn(tracker, 'reset');
- tracker.handleInput();
- expect(tracker.reset).toHaveBeenCalled();
- });
-
it("can create issues", function () {
messageInput.val = function () { return "/create new issue"; };

0 comments on commit df8efca

Please sign in to comment.