From 55c0767f16e60e77e9d1b4d46698ddbf343ed8b1 Mon Sep 17 00:00:00 2001 From: Andres Ornelas Date: Mon, 24 May 2010 17:48:17 -0700 Subject: added dsl tests and select method --- test/scenario/DSLSpec.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 test/scenario/DSLSpec.js (limited to 'test/scenario') diff --git a/test/scenario/DSLSpec.js b/test/scenario/DSLSpec.js new file mode 100644 index 00000000..3c16876d --- /dev/null +++ b/test/scenario/DSLSpec.js @@ -0,0 +1,40 @@ +describe("DSL", function() { + + var lastStep, executeStep, lastDocument; + + beforeEach(function() { + lastStep = null; + $scenario = { + addStep: function(name, stepFunction) { + lastStep = { name:name, fn: stepFunction}; + } + }; + executeStep = function(step, html, callback) { + lastDocument =_jQuery('
' + html + '
'); + var specThis = { + testWindow: window, + testDocument: lastDocument + }; + step.fn.call(specThis, callback || noop); + }; + }); + + describe("input", function() { + + var input = angular.scenario.dsl.input; + it('should enter', function() { + input('name').enter('John'); + expect(lastStep.name).toEqual("Set input text of 'name' to 'John'"); + executeStep(lastStep, ''); + expect(lastDocument.find('input').val()).toEqual('John'); + }); + + it('should select', function() { + input('gender').select('female'); + expect(lastStep.name).toEqual("Select radio 'gender' to 'female'"); + executeStep(lastStep, '' + + ''); + expect(lastDocument.find(':radio:checked').val()).toEqual('female'); + }); + }); +}); \ No newline at end of file -- cgit v1.2.3