Move custom matcher specs to their own suite.
This commit is contained in:
parent
40ff1cb4c8
commit
72b5ede0da
@ -35,6 +35,7 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
(function () {
|
(function () {
|
||||||
var suites = [
|
var suites = [
|
||||||
|
'suites/CustomMatchersSpec.js',
|
||||||
'suites/EnvSpec.js',
|
'suites/EnvSpec.js',
|
||||||
'suites/ExceptionsSpec.js',
|
'suites/ExceptionsSpec.js',
|
||||||
'suites/JsApiReporterSpec.js',
|
'suites/JsApiReporterSpec.js',
|
||||||
|
41
spec/suites/CustomMatchersSpec.js
Normal file
41
spec/suites/CustomMatchersSpec.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
describe("Custom Matchers", function() {
|
||||||
|
var env;
|
||||||
|
var fakeTimer;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
env = new jasmine.Env();
|
||||||
|
env.updateInterval = 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should be easy to add more matchers local to a spec, suite, etc.", function() {
|
||||||
|
var spec1, spec2, spec1Matcher, spec2Matcher;
|
||||||
|
|
||||||
|
var suite = env.describe('some suite', function() {
|
||||||
|
env.beforeEach(function() {
|
||||||
|
this.addMatchers({ matcherForSuite: function(expected) {
|
||||||
|
return "matcherForSuite: actual: " + this.actual + "; expected: " + expected;
|
||||||
|
} });
|
||||||
|
});
|
||||||
|
|
||||||
|
spec1 = env.it('spec with an expectation').runs(function () {
|
||||||
|
this.addMatchers({ matcherForSpec: function(expected) {
|
||||||
|
return "matcherForSpec: actual: " + this.actual + "; expected: " + expected;
|
||||||
|
} });
|
||||||
|
spec1Matcher = this.expect("xxx");
|
||||||
|
});
|
||||||
|
|
||||||
|
spec2 = env.it('spec with failing expectation').runs(function () {
|
||||||
|
spec2Matcher = this.expect("yyy");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
suite.execute();
|
||||||
|
|
||||||
|
expect(spec1Matcher.matcherForSuite("expected")).toEqual("matcherForSuite: actual: xxx; expected: expected");
|
||||||
|
expect(spec1Matcher.matcherForSpec("expected")).toEqual("matcherForSpec: actual: xxx; expected: expected");
|
||||||
|
|
||||||
|
expect(spec2Matcher.matcherForSuite("expected")).toEqual("matcherForSuite: actual: yyy; expected: expected");
|
||||||
|
expect(spec2Matcher.matcherForSpec).toBe(jasmine.undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@ -1083,35 +1083,4 @@ describe("jasmine spec running", function () {
|
|||||||
expect(exceptionMessage).toEqual('explodes function should not have been called');
|
expect(exceptionMessage).toEqual('explodes function should not have been called');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be easy to add more matchers local to a spec, suite, etc.", function() {
|
|
||||||
var spec1, spec2, spec1Matcher, spec2Matcher;
|
|
||||||
|
|
||||||
var suite = env.describe('some suite', function() {
|
|
||||||
env.beforeEach(function() {
|
|
||||||
this.addMatchers({ matcherForSuite: function(expected) {
|
|
||||||
return "matcherForSuite: actual: " + this.actual + "; expected: " + expected;
|
|
||||||
} });
|
|
||||||
});
|
|
||||||
|
|
||||||
spec1 = env.it('spec with an expectation').runs(function () {
|
|
||||||
this.addMatchers({ matcherForSpec: function(expected) {
|
|
||||||
return "matcherForSpec: actual: " + this.actual + "; expected: " + expected;
|
|
||||||
} });
|
|
||||||
spec1Matcher = this.expect("xxx");
|
|
||||||
});
|
|
||||||
|
|
||||||
spec2 = env.it('spec with failing expectation').runs(function () {
|
|
||||||
spec2Matcher = this.expect("yyy");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
suite.execute();
|
|
||||||
|
|
||||||
expect(spec1Matcher.matcherForSuite("expected")).toEqual("matcherForSuite: actual: xxx; expected: expected");
|
|
||||||
expect(spec1Matcher.matcherForSpec("expected")).toEqual("matcherForSpec: actual: xxx; expected: expected");
|
|
||||||
|
|
||||||
expect(spec2Matcher.matcherForSuite("expected")).toEqual("matcherForSuite: actual: yyy; expected: expected");
|
|
||||||
expect(spec2Matcher.matcherForSpec).toBe(jasmine.undefined);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user