Skip to content

Instantly share code, notes, and snippets.

it should add a task to the list, expected: 1 result: 0
Todos.mainPage = SC.Page.design({
mainPane: SC.MainPane.design({
childViews: 'topView middleView bottomView'.w(),
topView: SC.ToolbarView.design({
childViews: 'addTaskButton'.w(),
addTaskButton: SC.ButtonView.design({
target: 'Todos.tasksController', //ADDED THIS
action: 'addTask', //ADDED THIS
var controller, stubbedFunction;
module("Todos.tasksController", {
setup: function() {
controller = Todos.tasksController;
},
teardown: function() {
SC.RunLoop.begin();
Todos.store.reset();
SC.RunLoop.end();
Died on test #1: TypeError: Result of expression 'controller.addTask' [undefined] is not a function.
Todos.tasksController = SC.ArrayController.create({
countSummary: function() {
var length = this.get('length');
if(length == 0)
return 'No Tasks';
else
return length == 1 ? '1 Task' : "%@ Tasks".fmt(length);
}.property('length').cacheable(),
Delegates to the store to create the record, expected: 1 result: 0
Todos.tasksController = SC.ArrayController.create({
countSummary: function() {
var length = this.get('length');
if(length == 0)
return 'No Tasks';
else
return length == 1 ? '1 Task' : "%@ Tasks".fmt(length);
}.property('length').cacheable(),
Todos.mainPage = SC.Page.design({
mainPane: SC.MainPane.design({
childViews: 'topView middleView bottomView'.w(),
topView: SC.ToolbarView.design({
layout: {top: 0, left: 0, right: 0, height: 36 }, //ADDED THIS
anchorLocation: SC.ANCHOR_TOP, //ADDED THIS
childViews: 'addTaskButton'.w(),
addTaskButton: SC.ButtonView.design({
Then I should see "No Tasks" within the tasks count section of the page, expected No Tasks result ""
//Replace instances which look like:
Todos.getPath('mainPage.mainPane.middleView.contentView')
//With something that looks like this:
Todos.mainPage.todosList();
//And add the following to main_page.js
Todos.mainPage = SC.Page.design({
todosList: SC.outlet('mainPane.middleView.contentView'),
...
})