Skip to content

Commit 04c4295

Browse files
authored
Merge pull request #190 from ember-learn/prep-for-beta
3.27
2 parents df143a2 + 4bf854e commit 04c4295

10 files changed

+734
-922
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"postbuild": "yarn lint:md:dist"
6767
},
6868
"volta": {
69-
"node": "12.18.3",
70-
"yarn": "1.22.4"
69+
"node": "12.22.1",
70+
"yarn": "1.22.10"
7171
}
7272
}

src/markdown/tutorial/part-1/03-automated-testing.md

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,6 @@ In this case, we generated an *[acceptance test](../../../testing/test-types/#to
4545
git add tests/acceptance/super-rentals-test.js
4646
```
4747

48-
<!-- patch for https://github.com/emberjs/ember.js/issues/19333 -->
49-
50-
```run:file:patch hidden=true cwd=super-rentals filename=tests/acceptance/super-rentals-test.js
51-
@@ -4,6 +4,6 @@
52-
53-
-module('Acceptance | super rentals', function(hooks) {
54-
+module('Acceptance | super rentals', function (hooks) {
55-
setupApplicationTest(hooks);
56-
57-
- test('visiting /super-rentals', async function(assert) {
58-
+ test('visiting /super-rentals', async function (assert) {
59-
await visit('/super-rentals');
60-
```
61-
62-
```run:command hidden=true cwd=super-rentals
63-
git add tests/acceptance/super-rentals-test.js
64-
```
65-
66-
<!-- end patch for https://github.com/emberjs/ember.js/issues/19333 -->
67-
6848
Generators aren't required; we *could* have created the file ourselves which would have accomplished the exact same thing. But, generators certainly save us a lot of typing. Go ahead and take a peek at the acceptance test file and see for yourself.
6949

7050
> Zoey says...

src/markdown/tutorial/part-1/04-component-basics.md

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -153,29 +153,6 @@ ember generate component-test jumbo
153153
git add tests/integration/components/jumbo-test.js
154154
```
155155

156-
<!-- patch for https://github.com/emberjs/ember.js/issues/19333 -->
157-
158-
```run:file:patch hidden=true cwd=super-rentals filename=tests/integration/components/jumbo-test.js
159-
@@ -5,8 +5,8 @@
160-
161-
-module('Integration | Component | jumbo', function(hooks) {
162-
+module('Integration | Component | jumbo', function (hooks) {
163-
setupRenderingTest(hooks);
164-
165-
- test('it renders', async function(assert) {
166-
+ test('it renders', async function (assert) {
167-
// Set any properties with this.set('myProperty', 'value');
168-
- // Handle any actions with this.set('myAction', function(val) { ... });
169-
+ // Handle any actions with this.set('myAction', function (val) { ... });
170-
171-
```
172-
173-
```run:command hidden=true cwd=super-rentals
174-
git add tests/integration/components/jumbo-test.js
175-
```
176-
177-
<!-- end patch for https://github.com/emberjs/ember.js/issues/19333 -->
178-
179156
Here, we used the generator to generate a *[component test](../../../testing/testing-components/)*, also known as a rendering test. These are used to render and test a single component at a time. This is in contrast to the acceptance tests that we wrote earlier, which have to navigate and render entire pages worth of content.
180157

181158
Let's replace the boilerplate code that was generated for us with our own test:
@@ -185,11 +162,11 @@ Let's replace the boilerplate code that was generated for us with our own test:
185162

186163
- test('it renders', async function (assert) {
187164
- // Set any properties with this.set('myProperty', 'value');
188-
- // Handle any actions with this.set('myAction', function (val) { ... });
165+
- // Handle any actions with this.set('myAction', function(val) { ... });
189166
-
190167
- await render(hbs`<Jumbo />`);
191168
-
192-
- assert.equal(this.element.textContent.trim(), '');
169+
- assert.dom(this.element).hasText('');
193170
-
194171
- // Template block usage:
195172
- await render(hbs`
@@ -198,7 +175,7 @@ Let's replace the boilerplate code that was generated for us with our own test:
198175
- </Jumbo>
199176
- `);
200177
-
201-
- assert.equal(this.element.textContent.trim(), 'template block text');
178+
- assert.dom(this.element).hasText('template block text');
202179
+ test('it renders the content inside a jumbo header with a tomster', async function (assert) {
203180
+ await render(hbs`<Jumbo>Hello World</Jumbo>`);
204181
+

src/markdown/tutorial/part-1/05-more-about-components.md

Lines changed: 6 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,6 @@ git add app/components/rental.hbs
3131
git add tests/integration/components/rental-test.js
3232
```
3333

34-
<!-- patch for https://github.com/emberjs/ember.js/issues/19333 -->
35-
36-
```run:file:patch hidden=true cwd=super-rentals filename=tests/integration/components/rental-test.js
37-
@@ -5,8 +5,8 @@
38-
39-
-module('Integration | Component | rental', function(hooks) {
40-
+module('Integration | Component | rental', function (hooks) {
41-
setupRenderingTest(hooks);
42-
43-
- test('it renders', async function(assert) {
44-
+ test('it renders', async function (assert) {
45-
// Set any properties with this.set('myProperty', 'value');
46-
- // Handle any actions with this.set('myAction', function(val) { ... });
47-
+ // Handle any actions with this.set('myAction', function (val) { ... });
48-
49-
```
50-
51-
```run:command hidden=true cwd=super-rentals
52-
git add tests/integration/components/rental-test.js
53-
```
54-
55-
<!-- end patch for https://github.com/emberjs/ember.js/issues/19333 -->
56-
5734
We will start by editing the template. Let's *[hard-code](https://en.wikipedia.org/wiki/Hard_coding)* the details for one rental property for now, and replace it with the real data from the server later on.
5835

5936
```run:file:patch lang=handlebars cwd=super-rentals filename=app/components/rental.hbs
@@ -86,11 +63,11 @@ Then, we will write a test to ensure all of the details are present. We will rep
8663

8764
- test('it renders', async function (assert) {
8865
- // Set any properties with this.set('myProperty', 'value');
89-
- // Handle any actions with this.set('myAction', function (val) { ... });
66+
- // Handle any actions with this.set('myAction', function(val) { ... });
9067
-
9168
- await render(hbs`<Rental />`);
9269
-
93-
- assert.equal(this.element.textContent.trim(), '');
70+
- assert.dom(this.element).hasText('');
9471
-
9572
- // Template block usage:
9673
- await render(hbs`
@@ -99,7 +76,7 @@ Then, we will write a test to ensure all of the details are present. We will rep
9976
- </Rental>
10077
- `);
10178
-
102-
- assert.equal(this.element.textContent.trim(), 'template block text');
79+
- assert.dom(this.element).hasText('template block text');
10380
+ test('it renders information about a rental property', async function (assert) {
10481
+ await render(hbs`<Rental />`);
10582
+
@@ -170,30 +147,6 @@ git add app/components/rental/image.hbs
170147
git add tests/integration/components/rental/image-test.js
171148
```
172149
173-
<!-- patch for https://github.com/emberjs/ember.js/issues/19333 -->
174-
175-
```run:file:patch hidden=true cwd=super-rentals filename=tests/integration/components/rental/image-test.js
176-
@@ -5,8 +5,8 @@
177-
178-
-module('Integration | Component | rental/image', function(hooks) {
179-
+module('Integration | Component | rental/image', function (hooks) {
180-
setupRenderingTest(hooks);
181-
182-
- test('it renders', async function(assert) {
183-
+ test('it renders', async function (assert) {
184-
// Set any properties with this.set('myProperty', 'value');
185-
- // Handle any actions with this.set('myAction', function(val) { ... });
186-
+ // Handle any actions with this.set('myAction', function (val) { ... });
187-
188-
```
189-
190-
```run:command hidden=true cwd=super-rentals
191-
git add tests/integration/components/rental/image-test.js
192-
```
193-
194-
<!-- end patch for https://github.com/emberjs/ember.js/issues/19333 -->
195-
196-
197150
Components like these are known as *[namespaced](https://en.wikipedia.org/wiki/Namespace)* components. Namespacing allows us to organize our components by folders according to their purpose. This is completely optional&mdash;namespaced components are not special in any way.
198151
199152
## Forwarding HTML Attributes with `...attributes`
@@ -239,11 +192,11 @@ Let's write a test for our new component!
239192

240193
- test('it renders', async function (assert) {
241194
- // Set any properties with this.set('myProperty', 'value');
242-
- // Handle any actions with this.set('myAction', function (val) { ... });
195+
- // Handle any actions with this.set('myAction', function(val) { ... });
243196
-
244197
- await render(hbs`<Rental::Image />`);
245198
-
246-
- assert.equal(this.element.textContent.trim(), '');
199+
- assert.dom(this.element).hasText('');
247200
-
248201
- // Template block usage:
249202
- await render(hbs`
@@ -252,7 +205,7 @@ Let's write a test for our new component!
252205
- </Rental::Image>
253206
- `);
254207
-
255-
- assert.equal(this.element.textContent.trim(), 'template block text');
208+
- assert.dom(this.element).hasText('template block text');
256209
+ test('it renders the given image', async function (assert) {
257210
+ await render(hbs`
258211
+ <Rental::Image

src/markdown/tutorial/part-1/06-interactive-components.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,14 @@ This generated a JavaScript file with the same name as our component's template
5454
Ember will create an *[instance][TODO: link to instance]* of the class whenever our component is invoked. We can use that instance to store our state:
5555

5656
```run:file:patch lang=js cwd=super-rentals filename=app/components/rental/image.js
57-
@@ -3,2 +3,6 @@
58-
export default class RentalImageComponent extends Component {
57+
@@ -3 +3,6 @@
58+
-export default class RentalImageComponent extends Component {}
59+
+export default class RentalImageComponent extends Component {
5960
+ constructor(...args) {
6061
+ super(...args);
6162
+ this.isLarge = false;
6263
+ }
63-
}
64+
+}
6465
```
6566

6667
Here, in the *[component's constructor][TODO: link to component's constructor]*, we *[initialized][TODO: link to initialized]* the *[instance variable][TODO: link to instance variable]* `this.isLarge` with the value `false`, since this is the default state that we want for our component.

src/markdown/tutorial/part-1/07-reusable-components.md

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -98,43 +98,21 @@ git add app/components/map.js
9898
git add tests/integration/components/map-test.js
9999
```
100100

101-
<!-- patch for https://github.com/emberjs/ember.js/issues/19333 -->
102-
103-
```run:file:patch hidden=true cwd=super-rentals filename=tests/integration/components/map-test.js
104-
@@ -5,8 +5,8 @@
105-
106-
-module('Integration | Component | map', function(hooks) {
107-
+module('Integration | Component | map', function (hooks) {
108-
setupRenderingTest(hooks);
109-
110-
- test('it renders', async function(assert) {
111-
+ test('it renders', async function (assert) {
112-
// Set any properties with this.set('myProperty', 'value');
113-
- // Handle any actions with this.set('myAction', function(val) { ... });
114-
+ // Handle any actions with this.set('myAction', function (val) { ... });
115-
116-
```
117-
118-
```run:command hidden=true cwd=super-rentals
119-
git add tests/integration/components/map-test.js
120-
```
121-
122-
<!-- end patch for https://github.com/emberjs/ember.js/issues/19333 -->
123-
124101
## Parameterizing Components with Arguments
125102

126103
Let's start with our JavaScript file:
127104

128105
```run:file:patch lang=js cwd=super-rentals filename=app/components/map.js
129-
@@ -1,4 +1,8 @@
106+
@@ -1,3 +1,8 @@
130107
import Component from '@glimmer/component';
131108
+import ENV from 'super-rentals/config/environment';
132109

133-
export default class MapComponent extends Component {
110+
-export default class MapComponent extends Component {}
111+
+export default class MapComponent extends Component {
134112
+ get token() {
135113
+ return encodeURIComponent(ENV.MAPBOX_ACCESS_TOKEN);
136114
+ }
137-
}
115+
+}
138116
```
139117

140118
Here, we import the access token from the config file and return it from a `token` *[getter](https://javascript.info/property-accessors)*. This allows us to access our token as `this.token` both inside the `MapComponent` class body, as well as the component's template. It is also important to [URL-encode](https://javascript.info/url#encoding-strings) the token, just in case it contains any special characters that are not URL-safe.
@@ -193,7 +171,7 @@ We just added a lot of behavior into a single component, so let's write some tes
193171

194172
- test('it renders', async function (assert) {
195173
- // Set any properties with this.set('myProperty', 'value');
196-
- // Handle any actions with this.set('myAction', function (val) { ... });
174+
- // Handle any actions with this.set('myAction', function(val) { ... });
197175
+ test('it renders a map image for the specified parameters', async function (assert) {
198176
+ await render(hbs`<Map
199177
+ @lat="37.7797"
@@ -212,7 +190,7 @@ We just added a lot of behavior into a single component, so let's write some tes
212190
+ .hasAttribute('width', '150')
213191
+ .hasAttribute('height', '120');
214192

215-
- assert.equal(this.element.textContent.trim(), '');
193+
- assert.dom(this.element).hasText('');
216194
+ let { src } = find('.map img');
217195
+ let token = encodeURIComponent(ENV.MAPBOX_ACCESS_TOKEN);
218196

@@ -227,7 +205,7 @@ We just added a lot of behavior into a single component, so let's write some tes
227205
+ 'the src starts with "https://api.mapbox.com/"'
228206
+ );
229207

230-
- assert.equal(this.element.textContent.trim(), 'template block text');
208+
- assert.dom(this.element).hasText('template block text');
231209
+ assert.ok(
232210
+ src.includes('-122.4184,37.7797,10'),
233211
+ 'the src should include the lng,lat,zoom parameter'

src/markdown/tutorial/part-2/09-route-params.md

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -177,30 +177,6 @@ git add app/components/rental/detailed.hbs
177177
git add tests/integration/components/rental/detailed-test.js
178178
```
179179
180-
<!-- patch for https://github.com/emberjs/ember.js/issues/19333 -->
181-
182-
```run:file:patch hidden=true cwd=super-rentals filename=tests/integration/components/rental/detailed-test.js
183-
@@ -5,8 +5,8 @@
184-
185-
-module('Integration | Component | rental/detailed', function(hooks) {
186-
+module('Integration | Component | rental/detailed', function (hooks) {
187-
setupRenderingTest(hooks);
188-
189-
- test('it renders', async function(assert) {
190-
+ test('it renders', async function (assert) {
191-
// Set any properties with this.set('myProperty', 'value');
192-
- // Handle any actions with this.set('myAction', function(val) { ... });
193-
+ // Handle any actions with this.set('myAction', function (val) { ... });
194-
195-
```
196-
197-
```run:command hidden=true cwd=super-rentals
198-
git add tests/integration/components/rental/detailed-test.js
199-
```
200-
201-
<!-- end patch for https://github.com/emberjs/ember.js/issues/19333 -->
202-
203-
204180
```run:file:patch lang=handlebars cwd=super-rentals filename=app/components/rental/detailed.hbs
205181
@@ -1 +1,44 @@
206182
-{{yield}}
@@ -267,7 +243,7 @@ Now that we have this template in place, we can add some tests for this new comp
267243

268244
- test('it renders', async function (assert) {
269245
- // Set any properties with this.set('myProperty', 'value');
270-
- // Handle any actions with this.set('myAction', function (val) { ... });
246+
- // Handle any actions with this.set('myAction', function(val) { ... });
271247
+ hooks.beforeEach(function () {
272248
+ this.setProperties({
273249
+ rental: {
@@ -294,7 +270,7 @@ Now that we have this template in place, we can add some tests for this new comp
294270
+ test('it renders a header with a share button', async function (assert) {
295271
+ await render(hbs`<Rental::Detailed @rental={{this.rental}} />`);
296272

297-
- assert.equal(this.element.textContent.trim(), '');
273+
- assert.dom(this.element).hasText('');
298274
+ assert.dom('.jumbo').exists();
299275
+ assert.dom('.jumbo h2').containsText('Grand Old Mansion');
300276
+ assert
@@ -312,7 +288,7 @@ Now that we have this template in place, we can add some tests for this new comp
312288
+ test('it renders detailed information about a rental property', async function (assert) {
313289
+ await render(hbs`<Rental::Detailed @rental={{this.rental}} />`);
314290

315-
- assert.equal(this.element.textContent.trim(), 'template block text');
291+
- assert.dom(this.element).hasText('template block text');
316292
+ assert.dom('article').hasClass('rental');
317293
+ assert.dom('article h3').containsText('About Grand Old Mansion');
318294
+ assert.dom('article .detail.owner').containsText('Veruca Salt');

0 commit comments

Comments
 (0)