Java Reference
In-Depth Information
<!-- include spec files here... -->
<script type="text/javascript" src="spec/
numberSpec.js"></script>
Now, since we're doing TDD, we need to start writing the tests. Open up numberSpec.js
and add the following code:
spec/numberSpec.js (incomplete)
describe("The factorsOf() function", function() {
it("should find the factors of 12", function() {
expect(factorsOf(12)).toEqual([1,2,3,4,6,12]);
});
});
This is one description and one spec that says our factorsOf() function should return
an array containing the factors of 12 when 12 is provided as an argument. Let's run the test
now by opening SpecRunner.html in a browser. It should look similar to the screenshot in
Figure 10.2 .
Search WWH ::




Custom Search