@@ -348,6 +348,72 @@ \subsubsection{Bootstrapping the browser}
348348at development time through a script tag. Users could add this to the html
349349file they wished to test.
350350
351+ \subsection {Testing }
352+ \subsubsection {Enabling others }
353+ With the tool mainly exposing a means for others to plugin and create custom
354+ accessibility `checkers' it was important to demonstrate how developers can
355+ write tests to confirm their checkers. With this in mind a small collection
356+ of utility methods were created. The aim of these was to reduce the amount of
357+ boiler plate required to write the tests. For example when creating dom
358+ elements a test initially looked similar \ref {lst:before }.
359+ \ begin{lstlisting} [label={lst:before}]
360+ it('should expect only A elements: Negative test', () => {
361+ const actual = AChecker.expects(mount(<li></li>).getDOMNode());
362+ expect(actual).toBe(false);
363+ });
364+ \end {lstlisting }
365+
366+ But I kept on finding I was forgetting to add the .getDomNode on the end of
367+ the call to create the component. This therefore became a candidate for
368+ extraction. The effect was a much cleaner syntax as demonstrated below.
369+
370+ \ begin{lstlisting} [label={lst:before}]
371+ it('should expect only A elements: Negative test', () => {
372+ const actual = AChecker.expects(render(<li></li>));
373+ expect(actual).toBe(false);
374+ });
375+ \end {lstlisting }
376+
377+
378+ \subsubsection {The A11Y tool }
379+ Unit testing of the tool was completed using Jest \citep {jest } with jasmine
380+ \citep {jasmine }. These are two frameworks which interlink well
381+ together and offer a simple means to drive web based APIs. Below is a snippet
382+ of some tests for a HREF Checker whos purpose is to check anchor html elements
383+ for correct href attributes.
384+
385+ Note how each test increases the functionality expected of the checker which
386+ enables checking of regressions every time it is excuted. This model was
387+ applied accross most of the code base.
388+
389+ \ begin{lstlisting}
390+ describe('The Link Checker should', () => {
391+
392+ it('should expect only A elements: Negative test', () => {
393+ const actual = AChecker.expects(render(<li></li>));
394+ expect(actual).toBe(false);
395+ });
396+
397+ it('should expect only A elements: Positive test', () => {
398+ const actual = AChecker.expects(render(<a></a>));
399+ expect(actual).toBe(true);
400+ });
401+
402+ it('should return an error when there is no HREF present', () => {
403+ const HTML = render(<a></a>);
404+ const actual = new AChecker().execute(HTML);
405+ expect(actual.detail.moreInfo).toBe('No HREF present');
406+ });
407+
408+ it('should return an error when the HREF is only a #', () => {
409+ const HTML = render(<a href="#"></a>);
410+ const actual = new AChecker().execute(HTML);
411+ expect(actual.detail.moreInfo).toBe('HREF should go to an anchor on the page. \'#\' is not one of these!');
412+ });
413+
414+ ...
415+ \end {lstlisting }
416+
351417
352418% \newthought{Lorem ipsum dolor sit amet},
353419%
0 commit comments