Last active
December 25, 2015 21:19
-
-
Save iampeterbanjo/7041182 to your computer and use it in GitHub Desktop.
Problem testing Alloy controllers based on alloy-unit-test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('create with 2 items', function () { | |
item.set({ | |
title: "The cloud atlas", | |
author: "David Mitchell" | |
}); | |
item.save(); | |
item.set({ | |
title: "Design of design", | |
author: "Brooks" | |
}); | |
item.save(); | |
$ = Alloy.createController('index', {}); | |
Ti.API.info(JSON.stringify($.table.getData())) | |
expect($.table.getData().length).toEqual(2); | |
}); | |
/* | |
[ERROR] THERE WERE FAILURES! | |
[ERROR] ============================================================ | |
[ERROR] Recap of failing specs: | |
[ERROR] ------------------------------------------------------------ | |
[ERROR] index controller create with 1 item. - Expected 1 to equal 2. | |
[ERROR] ------------------------------------------------------------ | |
*/ |
Thanks! That works :-)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, iampeterbanjo
There are two changes that have to be made.
One is to fix the assert, I've seen that you can get the data with the getSections() method
The other is that in order to add 2 items, we need 2 different variables, if not it returns only 1 item in the table view.
I'll fix the blog post with those two fixes.
The resulting code will be