A Twitch.tv viewer reward and games system.
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.

51 lines
1.5 KiB

12 years ago
  1. require('./helper');
  2. var Context = Mustache.Context;
  3. describe('A new Mustache.Context', function () {
  4. var context;
  5. beforeEach(function () {
  6. context = new Context({ name: 'parent', message: 'hi', a: { b: 'b' } });
  7. });
  8. it('is able to lookup properties of its own view', function () {
  9. assert.equal(context.lookup('name'), 'parent');
  10. });
  11. it('is able to lookup nested properties of its own view', function () {
  12. assert.equal(context.lookup('a.b'), 'b');
  13. });
  14. describe('when pushed', function () {
  15. beforeEach(function () {
  16. context = context.push({ name: 'child', c: { d: 'd' } });
  17. });
  18. it('returns the child context', function () {
  19. assert.equal(context.view.name, 'child');
  20. assert.equal(context.parent.view.name, 'parent');
  21. });
  22. it('is able to lookup properties of its own view', function () {
  23. assert.equal(context.lookup('name'), 'child');
  24. });
  25. it("is able to lookup properties of the parent context's view", function () {
  26. assert.equal(context.lookup('message'), 'hi');
  27. });
  28. it('is able to lookup nested properties of its own view', function () {
  29. assert.equal(context.lookup('c.d'), 'd');
  30. });
  31. it('is able to lookup nested properties of its parent view', function () {
  32. assert.equal(context.lookup('a.b'), 'b');
  33. });
  34. });
  35. });
  36. describe('Mustache.Context.make', function () {
  37. it('returns the same object when given a Context', function () {
  38. var context = new Context;
  39. assert.strictEqual(Context.make(context), context);
  40. });
  41. });