Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4b8ee9c

Browse files
author
Tobias Bosch
committed
added tests and detail page
1 parent 158b525 commit 4b8ee9c

File tree

7 files changed

+64
-20
lines changed

7 files changed

+64
-20
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ Description
66

77
Mobile version of Angulars sample application [phonecat](https://github.com/angular/angular-phonecat).
88

9+
Technologies
10+
------------
11+
12+
- jquery-mobile: Mobile Widgets
13+
- angular: Databinding
14+
- jasmine: Unit-Tests
15+
- jasmine-ui: Ui-Tests
16+
- js-test-driver: Automating Tests
17+
- requirejs: Modules and optimization
18+
- Maven: Overall build control
19+
20+
921
Live Versions
1022
-------------
1123

build-gh-pages.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Build script to update the branch gh-pages, which
2+
# contains the live copy of the demo.
3+
if $M2_HOME/bin/mvn package; then
4+
if git checkout gh-pages; then
5+
rm -fr *
6+
cp -r target/requirejs/output/ .
7+
git add .
8+
git commit -m "updated pages"
9+
git checkout master
10+
fi
11+
fi
12+

buildpages.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/main/webapp/index.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,15 @@ <h1>Phones</h1>
3737
</div>
3838

3939
<div data-role="page" id="phonedetail" ng:controller="PhoneDetailCtrl">
40-
<div data-role="header" data-backbtn="false">
41-
<h1>{{data.name}}</h1>
40+
<div data-role="header">
41+
<h1 class="phonename">{{data.name}}</h1>
42+
<a href="" data-rel="back" data-role="button">Back</a>
43+
</div>
44+
<div data-role="content">
45+
<div data-role="fieldcontain" class="phonedesc">{{data.description}}</div>
46+
<div data-role="fieldcontain" ng:repeat="image in data.images">
47+
<img ng:src="{{image}}" width="100%" class="phoneimg">
48+
</div>
4249
</div>
4350
</div>
4451

src/test/webapp/main-ui-html.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require([
22
"lib/jasmine-html",
3-
"ui/phonelistSpec"
3+
"ui/phonelistSpec",
4+
"ui/phonedetailSpec"
45
]);
56

67

src/test/webapp/main-ui-jstd.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require([
22
"lib/jasmine-jstd",
3-
"ui/phonelistSpec"
3+
"ui/phonelistSpec",
4+
"ui/phonedetailSpec"
45
]);
56

67

src/test/webapp/ui/phonedetailSpec.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
1-
/*
2-
describe('phonedetail', function() {
3-
it('should show the name of the phone with the id given ')
1+
define(['phonesTestData', 'ui/testutils', 'lib/jasmine', 'lib/jasmine-ui'], function(testData, testutils, jasmine) {
2+
describe('phonedetail', function() {
3+
var jqueryLoaded = function(window) {
4+
return !!window.$;
5+
};
6+
7+
it('should show the name, description and images of the phone with the id', function() {
8+
loadHtml('/phonecat-mobile/index.html#phonedetail', function(testwin) {
9+
testutils.addXhrMock(testwin, 'phones/10.json', true, testData.onePhoneDetail);
10+
testutils.setOnActivateArguments(testwin.PhoneDetailCtrl, {selectedPhone: {id:10}});
11+
}, jqueryLoaded);
12+
runs(function() {
13+
var $ = testframe().$;
14+
var page = testutils.getCurrentPage();
15+
var name = page.find('.phonename');
16+
expect($.trim(name.text())).toEqual(testData.onePhoneDetail.name);
17+
var desc = page.find('.phonedesc');
18+
expect($.trim(desc.text())).toEqual(testData.onePhoneDetail.description);
19+
var imgs = page.find('img.phoneimg');
20+
expect(imgs.length).toEqual(testData.onePhoneDetail.images.length);
21+
for (var i=0; i<imgs.length; i++) {
22+
expect($(imgs[i]).attr('src')).toEqual(testData.onePhoneDetail.images[i]);
23+
}
24+
});
25+
});
26+
});
27+
428
});
5-
*/

0 commit comments

Comments
 (0)