aboutsummaryrefslogtreecommitdiffstats
path: root/test/scenario/DescribeSpec.js
diff options
context:
space:
mode:
authorElliott Sprehn2010-10-08 16:43:40 -0700
committerElliott Sprehn2010-10-14 09:47:39 -0700
commit03df6cbddbb80186caf571e29957370b2ef9881c (patch)
treed5a321c8b207b464a5c8a300c422186e20e8ae31 /test/scenario/DescribeSpec.js
parent0f104317dff5628765e26cc68df7dd1175b2aa5e (diff)
downloadangular.js-03df6cbddbb80186caf571e29957370b2ef9881c.tar.bz2
New Angular Scenario runner and DSL system with redesigned HTML UI.
Uses the Jasmine syntax for tests, ex: describe('widgets', function() { it('should verify that basic widgets work', function(){ navigateTo('widgets.html'); input('text.basic').enter('Carlos'); expect(binding('text.basic')).toEqual('Carlos'); input('text.basic').enter('Carlos Santana'); expect(binding('text.basic')).not().toEqual('Carlos Boozer'); input('text.password').enter('secret'); expect(binding('text.password')).toEqual('secret'); expect(binding('text.hidden')).toEqual('hiddenValue'); expect(binding('gender')).toEqual('male'); input('gender').select('female'); expect(binding('gender')).toEqual('female'); }); }); Note: To create new UI's implement the interface shown in angular.scenario.ui.Html.
Diffstat (limited to 'test/scenario/DescribeSpec.js')
-rw-r--r--test/scenario/DescribeSpec.js85
1 files changed, 85 insertions, 0 deletions
diff --git a/test/scenario/DescribeSpec.js b/test/scenario/DescribeSpec.js
new file mode 100644
index 00000000..05129cfe
--- /dev/null
+++ b/test/scenario/DescribeSpec.js
@@ -0,0 +1,85 @@
+describe('angular.scenario.Describe', function() {
+ var log;
+ var root;
+
+ beforeEach(function() {
+ root = new angular.scenario.Describe();
+
+ /**
+ * Simple callback logging system. Use to assert proper order of calls.
+ */
+ log = function(text) {
+ log.text = log.text + text;
+ };
+ log.fn = function(text) {
+ return function(done){
+ log(text);
+ (done || angular.noop)();
+ };
+ };
+ log.reset = function() {
+ log.text = '';
+ };
+ log.reset();
+ });
+
+ it('should handle basic nested case', function() {
+ root.describe('A', function(){
+ this.beforeEach(log.fn('{'));
+ this.afterEach(log.fn('}'));
+ this.it('1', log.fn('1'));
+ this.describe('B', function(){
+ this.beforeEach(log.fn('('));
+ this.afterEach(log.fn(')'));
+ this.it('2', log.fn('2'));
+ });
+ });
+ var specs = root.getSpecs();
+ expect(specs.length).toEqual(2);
+
+ expect(specs[0].name).toEqual('2');
+ specs[0].fn();
+ expect(log.text).toEqual('{(2)}');
+
+ log.reset();
+ expect(specs[1].name).toEqual('1');
+ specs[1].fn();
+ expect(log.text).toEqual('{1}');
+ });
+
+ it('should link nested describe blocks with parent and children', function() {
+ root.describe('A', function() {
+ this.it('1', angular.noop);
+ this.describe('B', function() {
+ this.it('2', angular.noop);
+ this.describe('C', function() {
+ this.it('3', angular.noop);
+ });
+ });
+ });
+ var specs = root.getSpecs();
+ expect(specs[2].definition.parent).toEqual(root);
+ expect(specs[0].definition.parent).toEqual(specs[2].definition.children[0]);
+ });
+
+ it('should not process xit and xdescribe', function() {
+ root.describe('A', function() {
+ this.xit('1', angular.noop);
+ this.xdescribe('B', function() {
+ this.it('2', angular.noop);
+ this.describe('C', function() {
+ this.it('3', angular.noop);
+ });
+ });
+ });
+ var specs = root.getSpecs();
+ expect(specs.length).toEqual(0);
+ });
+
+ it('should create uniqueIds in the tree', function() {
+ angular.scenario.Describe.id = 0;
+ var a = new angular.scenario.Describe();
+ var b = new angular.scenario.Describe();
+ expect(a.id).toNotEqual(b.id);
+ });
+});