summaryrefslogtreecommitdiff
path: root/specs/dot-notation.yml
blob: c1fc1145d1f635c957a84e45ae6386dac2930ede (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
tests:
  - name: Basic Example
    desc: Dot notation should be a form of shorthand for sections.
    data: { person: { name: 'Joe' } }
    template: '"{{person.name}}" == "{{#person}}{{name}}{{/person}}"'
    expected: '"Joe" == "Joe"'

  - name: Arbitrary Depth
    desc: Dot notation should be functional to any level of nesting.
    data:
      a: { b: { c: { d: { e: { name: 'Phil' } } } } }
    template: '"{{a.b.c.d.e.name}}" == "Phil"'
    expected: '"Phil" == "Phil"'

  - name: Broken Chain
    desc: Any falsey value prior to the last part of the name should yield ''.
    data:
      a: { }
    template: '"{{a.b.c}}" == ""'
    expected: '"" == ""'

  - name: Broken Chain Resolution
    desc: Each part of a dotted name should be resolved only against its elder.
    data:
      a: { b: { } }
      c: { name: 'Jim' }
    template: '"{{a.b.c.name}}" == ""'
    expected: '"" == ""'

  - name: Initial Key Resolution
    desc: The first part of a dotted name should resolve as any other name.
    data:
      a: { b: { c: { d: { e: { name: 'Phil' } } } } }
      b: { c: { d: { e: { name: 'Wrong' } } } }
    template: '"{{#a}}{{b.c.d.e.name}}{{/a}}" == "Phil"'
    expected: '"Phil" == "Phil"'

  # Tag Compatibility

  - name: Unescaped Interpolation
    desc: Dot notation should be functional with all basic tag types.
    data: { person: { name: 'Joe' } }
    template: '"{{{person.name}}}" == "{{#person}}{{{name}}}{{/person}}"'
    expected: '"Joe" == "Joe"'

  - name: Sections (Truthy)
    desc: Dot notation should be functional with all basic tag types.
    data: { person: { present: true } }
    template: '"{{#person.present}}Here{{/person.present}}" == "Here"'
    expected: '"Here" == "Here"'

  - name: Sections (Falsey)
    desc: Dot notation should be functional with all basic tag types.
    data: { person: { present: false } }
    template: '"{{#person.present}}Here{{/person.present}}" == ""'
    expected: '"" == ""'

  - name: Inverted Sections (Truthy)
    desc: Dot notation should be functional with all basic tag types.
    data: { person: { present: true } }
    template: '"{{^person.present}}Not Here{{/person.present}}" == ""'
    expected: '"" == ""'

  - name: Inverted Sections (Falsey)
    desc: Dot notation should be functional with all basic tag types.
    data: { person: { present: false } }
    template: '"{{^person.present}}Not Here{{/person.present}}" == "Not Here"'
    expected: '"Not Here" == "Not Here"'