From 27784b6dec5ab81213288947c9741561d53ac2e2 Mon Sep 17 00:00:00 2001
From: Shyam Seshadri
Date: Wed, 11 Aug 2010 10:10:43 +0800
Subject: Change repeater dsl to collect and return an array of string contents
based on match
---
test/scenario/DSLSpec.js | 63 +++++++++++++++++++++++++++++++++---------------
1 file changed, 43 insertions(+), 20 deletions(-)
(limited to 'test/scenario')
diff --git a/test/scenario/DSLSpec.js b/test/scenario/DSLSpec.js
index 62de9d6c..f414db6d 100644
--- a/test/scenario/DSLSpec.js
+++ b/test/scenario/DSLSpec.js
@@ -42,6 +42,27 @@ describe("DSL", function() {
describe('repeater', function() {
var repeater = angular.scenario.dsl.repeater;
+ var html;
+ beforeEach(function() {
+ html = "
" +
+ "" +
+ "| " +
+ "John Marston" +
+ " | " +
+ "" +
+ "Red Dead Redemption" +
+ " | " +
+ "
" +
+ "" +
+ "| " +
+ "Nathan Drake" +
+ " | " +
+ "" +
+ "Uncharted" +
+ " | " +
+ "
" +
+ "
";
+ });
it('should count', function() {
var future = repeater('.repeater-row').count();
expect(future.name).toEqual("repeater '.repeater-row' count");
@@ -55,29 +76,31 @@ describe("DSL", function() {
expect(future.value).toEqual(2);
});
- it('should collect', function() {
- var future = repeater('.epic').collect();
- expect(future.name).toEqual("repeater '.epic' collect");
- executeFuture(future,
- "" +
- "" +
- "| John Marston | " +
- "Red Dead Redemption | " +
- "
" +
- "" +
- "| Nathan Drake | " +
- "Uncharted 2 | " +
- "
" +
- "
",
- function(value) {
- future.fulfill(value);
+ function assertFutureState(future, expectedName, expectedValue) {
+ expect(future.name).toEqual(expectedName);
+ executeFuture(future, html, function(value) {
+ future.fulfill(value);
});
expect(future.fulfilled).toBeTruthy();
- expect(future.value[0].boundTo('hero')).toEqual('John Marston');
- expect(future.value[0].boundTo('game')).toEqual('Red Dead Redemption');
- expect(future.value[1].boundTo('hero')).toEqual('Nathan Drake');
- expect(future.value[1].boundTo('game')).toEqual('Uncharted 2');
+ expect(future.value).toEqual(expectedValue);
+ }
+ it('should collect bindings', function() {
+ assertFutureState(repeater('.epic').collect('{{hero}}'),
+ "repeater '.epic' collect '{{hero}}'",
+ ['John Marston', 'Nathan Drake']);
+ assertFutureState(repeater('.epic').collect('{{game}}'),
+ "repeater '.epic' collect '{{game}}'",
+ ['Red Dead Redemption', 'Uncharted']);
+ });
+ it('should collect normal selectors', function() {
+ assertFutureState(repeater('.epic').collect('.hero-name'),
+ "repeater '.epic' collect '.hero-name'",
+ ['John Marston', 'Nathan Drake']);
+ assertFutureState(repeater('.epic').collect('.game-name'),
+ "repeater '.epic' collect '.game-name'",
+ ['Red Dead Redemption', 'Uncharted']);
});
+ it('should collect normal attributes', function() {});
});
describe('element', function() {
--
cgit v1.2.3
From 04e92a875344fb675f27355a8bae7a22d0a6ae63 Mon Sep 17 00:00:00 2001
From: Shyam Seshadri
Date: Thu, 12 Aug 2010 01:54:11 +0800
Subject: modify element dsl to understand angular bindings and return jquery
object for further checking
---
test/scenario/DSLSpec.js | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
(limited to 'test/scenario')
diff --git a/test/scenario/DSLSpec.js b/test/scenario/DSLSpec.js
index f414db6d..c8e30917 100644
--- a/test/scenario/DSLSpec.js
+++ b/test/scenario/DSLSpec.js
@@ -100,7 +100,9 @@ describe("DSL", function() {
"repeater '.epic' collect '.game-name'",
['Red Dead Redemption', 'Uncharted']);
});
- it('should collect normal attributes', function() {});
+ it('should collect normal attributes', function() {
+ //TODO(shyamseshadri) : Left as an exercise to the user
+ });
});
describe('element', function() {
@@ -118,24 +120,25 @@ describe("DSL", function() {
'' +
'';
});
+ function timeTravel(future) {
+ executeFuture(future, html, function(value) { future.fulfill(value); });
+ expect(future.fulfilled).toBeTruthy();
+ }
it('should find elements on the page and provide jquery api', function() {
var future = element('.reports-detail');
expect(future.name).toEqual("Find element '.reports-detail'");
- executeFuture(future, html, function(value) { future.fulfill(value); });
- expect(future.fulfilled).toBeTruthy();
+ timeTravel(future);
expect(future.value.text()).
toEqual('Description : Details...Date created: 01/01/01');
expect(future.value.find('.desc').text()).
toEqual('Description : Details...');
});
- it('should know how to find ng:bind elements on page', function() {
- var future = element('.reports-detail');
- expect(future.name).toEqual("Find element '.reports-detail'");
- executeFuture(future, html, function(value) { future.fulfill(value); });
- expect(future.fulfilled).toBeTruthy();
- expect(future.value.boundTo('report.description')).toEqual('Details...');
- expect(future.value.boundTo('report.creationDate')).toEqual('01/01/01');
- expect(future.value.boundTo('doesnotexist')).not.toBeDefined();
+ it('should find elements with angular syntax', function() {
+ var future = element('{{report.description}}');
+ expect(future.name).toEqual("Find element '{{report.description}}'");
+ timeTravel(future);
+ expect(future.value.text()).toEqual('Details...');
+ expect(future.value.attr('ng:bind')).toEqual('report.description');
});
});
});
--
cgit v1.2.3