> --
> You received this message because you are subscribed to the Google Groups "Jasmine" group.
> To post to this group, send email to jasmi...@googlegroups.com.
> To unsubscribe from this group, send email to jasmine-js+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/jasmine-js?hl=en.
>
>
I think you have some alternatives. The simplest:
it("fun with statics", function() {
var sa1 = new SiteAuditor();
SiteAuditor.ResetDefaultDate(2010, 10, 10);
expect(sa1.DefaultDate.getDate()).toEqual(10);
SiteAuditor.ResetDefaultDate(2001, 1, 1)
expect(sa1.DefaultDate.getDate()).toEqual(1);
});
I would frown on this implementation because I've been taught to
only test 1 thing per test, and that test is testing two. Thats just
something I've been taught though as part of tDD, I don't know the
rule still applies for BDD in particular.
I think a preferable implementation would be:
describe("fun with statics", function() {
var sa1;
beforeEach(function() {
sa1 = new SiteAuditor();
SiteAuditor.ResetDefaultDate(2010, 10, 10);
});
it("calling the static effects existing instances", function() {
expect(sa1.DefaultDate.getDate()).toEqual(10);
});
it("the second call to the static overwrites the first", function() {
SiteAuditor.ResetDefaultDate(2001, 1, 1)
expect(sa1.DefaultDate.getDate()).toEqual(1);
});
});
So this is two tests, and there will be two instances of
SiteAuditor() created, but it is testing the progression of behaviors.
This is slightly different from your original sample though in that
there is no intermediate call to sa1.DefaultDate.getDate() before the
second call to SiteAuditor.ResetDefaultDate. If getDate() has side
effects you need to include in your test progression, then the second
it() would need to be:
it("the second call to the static overrides the first", function() {
sa1.DefaultDate.getDate()
SiteAuditor.ResetDefaultDate(2001, 1, 1)
expect(sa1.DefaultDate.getDate()).toEqual(1);
});