You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 line
942B

  1. require('./helper');
  2. var Writer = Mustache.Writer;
  3. describe('A new Mustache.Writer', function () {
  4. var writer;
  5. describe('with a cached partial', function () {
  6. beforeEach(function () {
  7. writer = new Writer;
  8. });
  9. it('caches partials by content, not name', function () {
  10. writer.cachePartial('partial', 'partial one');
  11. assert.equal(writer.render('{{>partial}}'), 'partial one');
  12. writer.cachePartial('partial', 'partial two');
  13. assert.equal(writer.render('{{>partial}}'), 'partial two');
  14. });
  15. });
  16. describe('with a partial loader', function () {
  17. var partial;
  18. beforeEach(function () {
  19. partial = 'The content of the partial.';
  20. writer = new Writer(function (name) {
  21. assert.equal(name, 'partial');
  22. return partial;
  23. });
  24. });
  25. it('loads partials correctly', function () {
  26. assert.equal(writer.render('{{>partial}}'), partial);
  27. });
  28. });
  29. });