diff options
| author | Misko Hevery | 2012-03-23 14:03:24 -0700 | 
|---|---|---|
| committer | Misko Hevery | 2012-03-28 11:16:35 -0700 | 
| commit | 2430f52bb97fa9d682e5f028c977c5bf94c5ec38 (patch) | |
| tree | e7529b741d70199f36d52090b430510bad07f233 /test/ngScenario/matchersSpec.js | |
| parent | 944098a4e0f753f06b40c73ca3e79991cec6c2e2 (diff) | |
| download | angular.js-2430f52bb97fa9d682e5f028c977c5bf94c5ec38.tar.bz2 | |
chore(module): move files around in preparation for more modules
Diffstat (limited to 'test/ngScenario/matchersSpec.js')
| -rw-r--r-- | test/ngScenario/matchersSpec.js | 51 | 
1 files changed, 51 insertions, 0 deletions
diff --git a/test/ngScenario/matchersSpec.js b/test/ngScenario/matchersSpec.js new file mode 100644 index 00000000..7a5217d7 --- /dev/null +++ b/test/ngScenario/matchersSpec.js @@ -0,0 +1,51 @@ +'use strict'; + +describe('angular.scenario.matchers', function () { +  var matchers; + +  function expectMatcher(value, test) { +    delete matchers.error; +    delete matchers.future.value; +    if (value !== undefined) { +      matchers.future.value = value; +    } +    test(); +    expect(matchers.error).toBeUndefined(); +  } + +  beforeEach(function() { +    /** +     * Mock up the future system wrapped around matchers. +     * +     * @see Scenario.js#angular.scenario.matcher +     */ +    matchers = { +      future: { name: 'test' } +    }; +    matchers.addFuture = function(name, callback) { +      callback(function(error) { +        matchers.error = error; +      }); +    }; +    angular.extend(matchers, angular.scenario.matcher); +  }); + +  it('should handle basic matching', function() { +    expectMatcher(10, function() { matchers.toEqual(10); }); +    expectMatcher('value', function() { matchers.toBeDefined(); }); +    expectMatcher([1], function() { matchers.toBeTruthy(); }); +    expectMatcher("", function() { matchers.toBeFalsy(); }); +    expectMatcher(0, function() { matchers.toBeFalsy(); }); +    expectMatcher('foo', function() { matchers.toMatch('.o.'); }); +    expectMatcher(null, function() { matchers.toBeNull(); }); +    expectMatcher([1, 2, 3], function() { matchers.toContain(2); }); +    expectMatcher(3, function() { matchers.toBeLessThan(10); }); +    expectMatcher(3, function() { matchers.toBeGreaterThan(-5); }); +  }); + +  it('should have toHaveClass matcher', function(){ +    var e = angular.element('<div class="abc">'); +    expect(e).not.toHaveClass('none'); +    expect(e).toHaveClass('abc'); +  }); +});  | 
