fixed example rendering, add tests for it.

This commit is contained in:
Misko Hevery
2011-01-19 15:42:11 -08:00
parent 5d0d34ae72
commit c2f2587a79
46 changed files with 512 additions and 477 deletions

24
docs/spec/domSpec.js Normal file
View File

@@ -0,0 +1,24 @@
var DOM = require('dom.js').DOM;
describe('dom', function(){
describe('example', function(){
it('should render code, live, test', function(){
var dom = new DOM();
dom.example('desc', 'src', 'scenario');
expect(dom.toString()).toEqual('<h1>Example</h1>\ndesc<doc:example><doc:source>src</doc:source>\n<doc:scenario>scenario</doc:scenario>\n</doc:example>\n');
});
it('should render non-live, test with description', function(){
var dom = new DOM();
dom.example('desc', 'src', false);
expect(dom.toString()).toEqual('<h1>Example</h1>\ndesc<div ng:non-bindable=""><pre class="brush: js; html-script: true;">src</pre>\n</div>\n');
});
it('should render non-live, test', function(){
var dom = new DOM();
dom.example('desc', 'src', false);
expect(dom.toString()).toContain('<pre class="brush: js; html-script: true;">src</pre>');
});
});
});

View File

@@ -279,6 +279,16 @@ describe('ngdoc', function(){
doc.parse();
expect(doc.html()).toContain('<p>some\n text');
});
it('should render description in related method', function(){
var doc = new Doc();
doc.ngdoc = 'service';
doc.methods = [new Doc('@ngdoc method\n@exampleDescription MDesc\n@example MExmp').parse()];
doc.properties = [new Doc('@ngdoc property\n@exampleDescription PDesc\n@example PExmp').parse()];
expect(doc.html()).toContain('<p>MDesc</p><div ng:non-bindable=""><pre class="brush: js; html-script: true;">MExmp</pre>');
expect(doc.html()).toContain('<p>PDesc</p><div ng:non-bindable=""><pre class="brush: js; html-script: true;">PExmp</pre>');
});
});
describe('@deprecated', function() {

View File

@@ -2,17 +2,17 @@ var writer = require('writer.js');
describe('writer', function(){
describe('toString', function(){
var toString = writer.toString;
it('should merge string', function(){
expect(toString('abc')).toEqual('abc');
});
it('should merge obj', function(){
expect(toString({a:1})).toEqual('{"a":1}');
});
it('should merge array', function(){
expect(toString(['abc',{}])).toEqual('abc{}');
});
});
});
});