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.

пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. var assert = require("assert");
  2. var vows = require("vows");
  3. var Context = require("./../mustache").Context;
  4. vows.describe("Mustache.Context").addBatch({
  5. "A Context": {
  6. topic: function () {
  7. var view = { name: 'parent', message: 'hi', a: { b: 'b' } };
  8. var context = new Context(view);
  9. return context;
  10. },
  11. "is able to lookup properties of its own view": function (context) {
  12. assert.equal(context.lookup("name"), "parent");
  13. },
  14. "is able to lookup nested properties of its own view": function (context) {
  15. assert.equal(context.lookup("a.b"), "b");
  16. },
  17. "when pushed": {
  18. topic: function (context) {
  19. var view = { name: 'child', c: { d: 'd' } };
  20. return context.push(view);
  21. },
  22. "returns the child context": function (context) {
  23. assert.equal(context.view.name, "child");
  24. assert.equal(context.parent.view.name, "parent");
  25. },
  26. "is able to lookup properties of its own view": function (context) {
  27. assert.equal(context.lookup("name"), "child");
  28. },
  29. "is able to lookup properties of the parent context's view": function (context) {
  30. assert.equal(context.lookup("message"), "hi");
  31. },
  32. "is able to lookup nested properties of its own view": function (context) {
  33. assert.equal(context.lookup("c.d"), "d");
  34. },
  35. "is able to lookup nested properties of its parent view": function (context) {
  36. assert.equal(context.lookup("a.b"), "b");
  37. }
  38. } // when pushed
  39. }, // A Context
  40. "make": {
  41. "returns the same object when given a Context": function () {
  42. var context = new Context;
  43. assert.strictEqual(Context.make(context), context);
  44. }
  45. }
  46. }).export(module);