mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-26 13:05:35 +08:00
fixed example rendering, add tests for it.
This commit is contained in:
24
docs/spec/domSpec.js
Normal file
24
docs/spec/domSpec.js
Normal 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>');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
@@ -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() {
|
||||
|
||||
@@ -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{}');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user