1
exercism fetch ecmascript kindergarten-garden

kindergarten-garden.spec.js

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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import Garden from './kindergarten-garden';

describe('Garden', () => {
  test('for Alice', () => {
    expect(new Garden('RC\nGG').alice)
      .toEqual(['radishes', 'clover', 'grass', 'grass']);
  });

  xtest('another for Alice', () => {
    expect(new Garden('VC\nRC').alice)
      .toEqual(['violets', 'clover', 'radishes', 'clover']);
  });

  xtest('for Bob', () => {
    expect(new Garden('VVCG\nVVRC').bob)
      .toEqual(['clover', 'grass', 'radishes', 'clover']);
  });

  xtest('for Bob and Charlie', () => {
    const garden = new Garden('VVCCGG\nVVCCGG');
    expect(garden.bob).toEqual(['clover', 'clover', 'clover', 'clover']);
    expect(garden.charlie).toEqual(['grass', 'grass', 'grass', 'grass']);
  });
});

describe('Full garden', () => {
  const diagram = 'VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV';
  const garden = new Garden(diagram);

  xtest('for Alice', () => {
    expect(garden.alice)
      .toEqual(['violets', 'radishes', 'violets', 'radishes']);
  });

  xtest('for Bob', () => {
    expect(garden.bob)
      .toEqual(['clover', 'grass', 'clover', 'clover']);
  });

  xtest('for Charlie', () => {
    expect(garden.charlie)
      .toEqual(['violets', 'violets', 'clover', 'grass']);
  });

  xtest('for David', () => {
    expect(garden.david)
      .toEqual(['radishes', 'violets', 'clover', 'radishes']);
  });

  xtest('for Eve', () => {
    expect(garden.eve)
      .toEqual(['clover', 'grass', 'radishes', 'grass']);
  });

  xtest('for Fred', () => {
    expect(garden.fred)
      .toEqual(['grass', 'clover', 'violets', 'clover']);
  });

  xtest('for Ginny', () => {
    expect(garden.ginny)
      .toEqual(['clover', 'grass', 'grass', 'clover']);
  });

  xtest('for Harriet', () => {
    expect(garden.harriet)
      .toEqual(['violets', 'radishes', 'radishes', 'violets']);
  });

  xtest('for Ileana', () => {
    expect(garden.ileana)
      .toEqual(['grass', 'clover', 'violets', 'clover']);
  });

  xtest('for Joseph', () => {
    expect(garden.joseph)
      .toEqual(['violets', 'clover', 'violets', 'grass']);
  });

  xtest('for Kincaid', () => {
    expect(garden.kincaid)
      .toEqual(['grass', 'clover', 'clover', 'grass']);
  });

  xtest('for Larry', () => {
    expect(garden.larry)
      .toEqual(['grass', 'violets', 'clover', 'violets']);
  });
});

describe('Disordered class', () => {
  const diagram = 'VCRRGVRG\nRVGCCGCV';
  const students = ['Samantha', 'Patricia', 'Xander', 'Roger'];
  const garden = new Garden(diagram, students);

  xtest('Patricia', () => {
    expect(garden.patricia)
      .toEqual(['violets', 'clover', 'radishes', 'violets']);
  });

  xtest('Roger', () => {
    expect(garden.roger)
      .toEqual(['radishes', 'radishes', 'grass', 'clover']);
  });

  xtest('Samantha', () => {
    expect(garden.samantha)
      .toEqual(['grass', 'violets', 'clover', 'grass']);
  });

  xtest('Xander', () => {
    expect(garden.xander)
      .toEqual(['radishes', 'grass', 'clover', 'violets']);
  });
});

describe('Two gardens, different students', () => {
  const diagram = 'VCRRGVRG\nRVGCCGCV';
  const garden1 = new Garden(diagram, ['Alice', 'Bob', 'Charlie', 'Dan']);
  const garden2 = new Garden(diagram, ['Bob', 'Charlie', 'Dan', 'Erin']);

  xtest('Bob and Charlie for each garden', () => {
    expect(garden1.bob)
      .toEqual(['radishes', 'radishes', 'grass', 'clover']);
    expect(garden2.bob)
      .toEqual(['violets', 'clover', 'radishes', 'violets']);
    expect(garden1.charlie)
      .toEqual(['grass', 'violets', 'clover', 'grass']);
    expect(garden2.charlie)
      .toEqual(['radishes', 'radishes', 'grass', 'clover']);
  });
});