Mojito markup test utility
Build Status
Overview
The markup layout test utility will render the mojit view with mock data and expose the resulting markup to be validated using YUI Node module.
Markup tests written with this utility will be run as regular mojito unit tests
using mojito test
command
Usage
Three easy steps:
- Require
mojito-markup-test
. - Add a mojit
spec
. - Render view and validate markup.
Mojit spec
You must specify the mojit and view to render, along with the mock data to use.
You can mock any data, including parameters, configuration, request and headers.
//describe the mojit to renderspec = //mojit type (dir name) type: 'SimpleMojit' //action to test action: 'index' //mojit params params: url: p: 'Really!' //mojit config (to use with ac.config.get() ) appConfig: foo: 'bar' //mock request/response and headers data req: p: 'flowers' res: {} headers: 'Content-Type': 'text/html' ;
Rendering views
Once you have the mojit spec, you can render the view invoking the utility's render
method.
render (spec, callback)
Receives the mojit spec and a callback function which will get the error (if any), the rendered markup string, the mojit view meta object and the node (YUI Node) for the resulting markup.
MarkupTest
Full example
YUI;
See more examples.