From 5607651c5eac1de22b5180ba14520a8eaad2e5c8 Mon Sep 17 00:00:00 2001 From: Valeriy Date: Sat, 27 Oct 2018 12:53:05 +0300 Subject: [PATCH] fix(curriculum): fix wrong tests sections in the backend challenges (#30137) --- .../exercise-tracker.en.md | 21 ++++++++-------- .../file-metadata-microservice.en.md | 9 ++++--- .../request-header-parser-microservice.en.md | 5 ++-- .../timestamp-microservice.en.md | 25 ++++++++++--------- .../url-shortener-microservice.en.md | 13 +++++----- ...n-middleware-to-create-a-time-server.en.md | 9 ++++--- .../get-data-from-post-requests.en.md | 9 ++++--- ...uery-parameter-input-from-the-client.en.md | 9 ++++--- ...oute-parameter-input-from-the-client.en.md | 9 ++++--- ...root-level-request-logger-middleware.en.md | 5 ++-- .../meet-the-node-console.en.md | 5 ++-- .../serve-an-html-file.en.md | 5 ++-- .../serve-json-on-a-specific-route.en.md | 5 ++-- .../serve-static-assets.en.md | 5 ++-- .../start-a-working-express-server.en.md | 5 ++-- ...e-body-parser-to-parse-post-requests.en.md | 5 ++-- .../use-the-.env-file.en.md | 5 ++-- ...d-a-description-to-your-package.json.en.md | 5 ++-- .../add-a-license-to-your-package.json.en.md | 5 ++-- .../add-a-version-to-your-package.json.en.md | 5 ++-- .../add-keywords-to-your-package.json.en.md | 13 +++++----- ...ject-with-external-packages-from-npm.en.md | 9 ++++--- ...f-any-node.js-project-or-npm-package.en.md | 5 ++-- ...by-understanding-semantic-versioning.en.md | 9 ++++--- ...ove-a-package-from-your-dependencies.en.md | 5 ++-- ...latest-minor-version-of-a-dependency.en.md | 9 ++++--- ...latest-patch-version-of-a-dependency.en.md | 9 ++++--- ...ery-helpers-to-narrow-search-results.en.md | 5 ++-- .../mongodb-and-mongoose/create-a-model.en.md | 5 ++-- .../create-and-save-a-record-of-a-model.en.md | 5 ++-- ...reate-many-records-with-model.create.en.md | 5 ++-- ...ete-many-documents-with-model.remove.en.md | 5 ++-- ...cument-using-model.findbyidandremove.en.md | 5 ++-- .../install-and-set-up-mongoose.en.md | 13 +++++----- ...dates-by-running-find-edit-then-save.en.md | 5 ++-- ...ocument-using-model.findoneandupdate.en.md | 5 ++-- ...e-model.find-to-search-your-database.en.md | 5 ++-- ...ndbyid-to-search-your-database-by-id.en.md | 5 ++-- ...matching-document-from-your-database.en.md | 5 ++-- 39 files changed, 165 insertions(+), 126 deletions(-) diff --git a/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/exercise-tracker.en.md b/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/exercise-tracker.en.md index fcf5bbd8e7..90d9e6329f 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/exercise-tracker.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/exercise-tracker.en.md @@ -21,16 +21,17 @@ Start this project on Glitch using ```yml -- text: I can create a user by posting form data username to /api/exercise/new-user and returned will be an object with username and _id. - testString: '' -- text: I can get an array of all users by getting api/exercise/users with the same info as when creating a user. - testString: '' -- text: 'I can add an exercise to any user by posting form data userId(_id), description, duration, and optionally date to /api/exercise/add. If no date supplied it will use current date. App will return the user object with the exercise fields added.' - testString: '' -- text: I can retrieve a full exercise log of any user by getting /api/exercise/log with a parameter of userId(_id). App will return the user object with added array log and count (total exercise count). - testString: '' -- text: 'I can retrieve part of the log of any user by also passing along optional parameters of from & to or limit. (Date format yyyy-mm-dd, limit = int)' - testString: '' +tests: + - text: I can create a user by posting form data username to /api/exercise/new-user and returned will be an object with username and _id. + testString: '' + - text: I can get an array of all users by getting api/exercise/users with the same info as when creating a user. + testString: '' + - text: 'I can add an exercise to any user by posting form data userId(_id), description, duration, and optionally date to /api/exercise/add. If no date supplied it will use current date. App will return the user object with the exercise fields added.' + testString: '' + - text: I can retrieve a full exercise log of any user by getting /api/exercise/log with a parameter of userId(_id). App will return the user object with added array log and count (total exercise count). + testString: '' + - text: 'I can retrieve part of the log of any user by also passing along optional parameters of from & to or limit. (Date format yyyy-mm-dd, limit = int)' + testString: '' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/file-metadata-microservice.en.md b/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/file-metadata-microservice.en.md index aa8482e780..dc3685efbf 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/file-metadata-microservice.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/file-metadata-microservice.en.md @@ -21,10 +21,11 @@ Start this project on Glitch using ```yml -- text: I can submit a FormData object that includes a file upload. - testString: '' -- text: 'When I submit something, I will receive the file size in bytes within the JSON response.' - testString: '' +tests: + - text: I can submit a FormData object that includes a file upload. + testString: '' + - text: 'When I submit something, I will receive the file size in bytes within the JSON response.' + testString: '' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/request-header-parser-microservice.en.md b/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/request-header-parser-microservice.en.md index c87a517ab9..2d446a0cac 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/request-header-parser-microservice.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/request-header-parser-microservice.en.md @@ -21,8 +21,9 @@ Start this project on Glitch using ```yml -- text: 'I can get the IP address, language and operating system for my browser.' - testString: '' +tests: + - text: 'I can get the IP address, language and operating system for my browser.' + testString: '' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/timestamp-microservice.en.md b/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/timestamp-microservice.en.md index e387c2eb13..3978776a7f 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/timestamp-microservice.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/timestamp-microservice.en.md @@ -21,18 +21,19 @@ Start this project on Glitch using ```yml -- text: 'It should handle a valid date, and return the correct unix timestamp' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/timestamp/2016-12-25'').then(data => { assert.equal(data.unix, 1482624000000, ''Should be a valid unix timestamp''); }, xhr => { throw new Error(xhr.responseText); })' -- text: 'It should handle a valid date, and return the correct UTC string' - testString: 'getUserInput => $.get(getUserInput(''url'')+ ''/api/timestamp/2016-12-25'').then(data => { assert.equal(data.utc, ''Sun, 25 Dec 2016 00:00:00 GMT'', ''Should be a valid UTC date string''); }, xhr => { throw new Error(xhr.responseText); })' -- text: 'It should handle a valid unix date, and return the correct unix timestamp' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/timestamp/1482624000000'').then(data => { assert.equal(data.unix, 1482624000000) ; }, xhr => { throw new Error(xhr.responseText); })' -- text: It should return the expected error message for an invalid date - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/timestamp/this-is-not-a-date'').then(data => { assert.equal(data.error.toLowerCase(), ''invalid date'');}, xhr => { throw new Error(xhr.responseText); })' -- text: 'It should handle an empty date parameter, and return the current time in unix format' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/timestamp'').then(data => { var now = Date.now(); assert.approximately(data.unix, now, 20000) ;}, xhr => { throw new Error(xhr.responseText); })' -- text: 'It should handle an empty date parameter, and return the current time in UTC format' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/timestamp'').then(data => { var now = Date.now(); var serverTime = (new Date(data.utc)).getTime(); assert.approximately(serverTime, now, 20000) ;}, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: 'It should handle a valid date, and return the correct unix timestamp' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/timestamp/2016-12-25'').then(data => { assert.equal(data.unix, 1482624000000, ''Should be a valid unix timestamp''); }, xhr => { throw new Error(xhr.responseText); })' + - text: 'It should handle a valid date, and return the correct UTC string' + testString: 'getUserInput => $.get(getUserInput(''url'')+ ''/api/timestamp/2016-12-25'').then(data => { assert.equal(data.utc, ''Sun, 25 Dec 2016 00:00:00 GMT'', ''Should be a valid UTC date string''); }, xhr => { throw new Error(xhr.responseText); })' + - text: 'It should handle a valid unix date, and return the correct unix timestamp' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/timestamp/1482624000000'').then(data => { assert.equal(data.unix, 1482624000000) ; }, xhr => { throw new Error(xhr.responseText); })' + - text: It should return the expected error message for an invalid date + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/timestamp/this-is-not-a-date'').then(data => { assert.equal(data.error.toLowerCase(), ''invalid date'');}, xhr => { throw new Error(xhr.responseText); })' + - text: 'It should handle an empty date parameter, and return the current time in unix format' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/timestamp'').then(data => { var now = Date.now(); assert.approximately(data.unix, now, 20000) ;}, xhr => { throw new Error(xhr.responseText); })' + - text: 'It should handle an empty date parameter, and return the current time in UTC format' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/timestamp'').then(data => { var now = Date.now(); var serverTime = (new Date(data.utc)).getTime(); assert.approximately(serverTime, now, 20000) ;}, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/url-shortener-microservice.en.md b/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/url-shortener-microservice.en.md index 9e57b860eb..61d2fa3ca1 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/url-shortener-microservice.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/url-shortener-microservice.en.md @@ -21,12 +21,13 @@ Start this project on Glitch using ```yml -- text: I can pass a URL as a parameter and I will receive a shortened URL in the JSON response. - testString: '' -- text: 'If I pass an invalid URL that doesn''t follow the valid http://www.example.com format, the JSON response will contain an error instead.' - testString: '' -- text: 'When I visit that shortened URL, it will redirect me to my original link.' - testString: '' +tests: + - text: I can pass a URL as a parameter and I will receive a shortened URL in the JSON response. + testString: '' + - text: 'If I pass an invalid URL that doesn''t follow the valid http://www.example.com format, the JSON response will contain an error instead.' + testString: '' + - text: 'When I visit that shortened URL, it will redirect me to my original link.' + testString: '' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/chain-middleware-to-create-a-time-server.en.md b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/chain-middleware-to-create-a-time-server.en.md index 02c1d611ba..01cb06d24e 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/chain-middleware-to-create-a-time-server.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/chain-middleware-to-create-a-time-server.en.md @@ -23,10 +23,11 @@ Hint: The test will not pass if you don’t chain the middleware. If you mount t
```yml -- text: The /now endpoint should have mounted middleware - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/chain-middleware-time'').then(data => { assert.equal(data.stackLength, 2, ''"/now" route has no mounted middleware''); }, xhr => { throw new Error(xhr.responseText); })' -- text: The /now endpoint should return a time that is +/- 20 secs from now - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/chain-middleware-time'').then(data => { var now = new Date(); assert.isAtMost(Math.abs(new Date(data.time) - now), 20000, ''the returned time is not between +- 20 secs from now''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: The /now endpoint should have mounted middleware + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/chain-middleware-time'').then(data => { assert.equal(data.stackLength, 2, ''"/now" route has no mounted middleware''); }, xhr => { throw new Error(xhr.responseText); })' + - text: The /now endpoint should return a time that is +/- 20 secs from now + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/chain-middleware-time'').then(data => { var now = new Date(); assert.isAtMost(Math.abs(new Date(data.time) - now), 20000, ''the returned time is not between +- 20 secs from now''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/get-data-from-post-requests.en.md b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/get-data-from-post-requests.en.md index afacdd13a9..7e1e00a660 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/get-data-from-post-requests.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/get-data-from-post-requests.en.md @@ -26,10 +26,11 @@ There are also a couple of other methods which are used to negotiate a connectio
```yml -- text: 'Test 1 : Your API endpoint should respond with the correct name' - testString: 'getUserInput => $.post(getUserInput(''url'') + ''/name'', {first: ''Mick'', last: ''Jagger''}).then(data => { assert.equal(data.name, ''Mick Jagger'', ''Test 1: "POST /name" route does not behave as expected'') }, xhr => { throw new Error(xhr.responseText); })' -- text: 'Test 2 : Your API endpoint should respond with the correct name' - testString: 'getUserInput => $.post(getUserInput(''url'') + ''/name'', {first: ''Keith'', last: ''Richards''}).then(data => { assert.equal(data.name, ''Keith Richards'', ''Test 2: "POST /name" route does not behave as expected'') }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: 'Test 1 : Your API endpoint should respond with the correct name' + testString: 'getUserInput => $.post(getUserInput(''url'') + ''/name'', {first: ''Mick'', last: ''Jagger''}).then(data => { assert.equal(data.name, ''Mick Jagger'', ''Test 1: "POST /name" route does not behave as expected'') }, xhr => { throw new Error(xhr.responseText); })' + - text: 'Test 2 : Your API endpoint should respond with the correct name' + testString: 'getUserInput => $.post(getUserInput(''url'') + ''/name'', {first: ''Keith'', last: ''Richards''}).then(data => { assert.equal(data.name, ''Keith Richards'', ''Test 2: "POST /name" route does not behave as expected'') }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/get-query-parameter-input-from-the-client.en.md b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/get-query-parameter-input-from-the-client.en.md index 6266275ee8..77fe82080c 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/get-query-parameter-input-from-the-client.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/get-query-parameter-input-from-the-client.en.md @@ -21,10 +21,11 @@ TIP: In the following exercise we are going to receive data from a POST request,
```yml -- text: 'Test 1 : Your API endpoint should respond with the correct name' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/name?first=Mick&last=Jagger'').then(data => { assert.equal(data.name, ''Mick Jagger'', ''Test 1: "GET /name" route does not behave as expected'') }, xhr => { throw new Error(xhr.responseText); })' -- text: 'Test 2 : Your APi endpoint should respond with the correct name' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/name?last=Richards&first=Keith'').then(data => { assert.equal(data.name, ''Keith Richards'', ''Test 2: "GET /name" route does not behave as expected'') }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: 'Test 1 : Your API endpoint should respond with the correct name' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/name?first=Mick&last=Jagger'').then(data => { assert.equal(data.name, ''Mick Jagger'', ''Test 1: "GET /name" route does not behave as expected'') }, xhr => { throw new Error(xhr.responseText); })' + - text: 'Test 2 : Your APi endpoint should respond with the correct name' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/name?last=Richards&first=Keith'').then(data => { assert.equal(data.name, ''Keith Richards'', ''Test 2: "GET /name" route does not behave as expected'') }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/get-route-parameter-input-from-the-client.en.md b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/get-route-parameter-input-from-the-client.en.md index c361be8e2e..8a6033c0bb 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/get-route-parameter-input-from-the-client.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/get-route-parameter-input-from-the-client.en.md @@ -20,10 +20,11 @@ Build an echo server, mounted at the route GET /:word/echo. Respond
```yml -- text: 'Test 1 : Your echo server should repeat words correctly' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/eChOtEsT/echo'').then(data => { assert.equal(data.echo, ''eChOtEsT'', ''Test 1: the echo server is not working as expected'') }, xhr => { throw new Error(xhr.responseText); })' -- text: 'Test 2 : Your echo server should repeat words correctly' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/ech0-t3st/echo'').then(data => { assert.equal(data.echo, ''ech0-t3st'', ''Test 2: the echo server is not working as expected'') }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: 'Test 1 : Your echo server should repeat words correctly' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/eChOtEsT/echo'').then(data => { assert.equal(data.echo, ''eChOtEsT'', ''Test 1: the echo server is not working as expected'') }, xhr => { throw new Error(xhr.responseText); })' + - text: 'Test 2 : Your echo server should repeat words correctly' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/ech0-t3st/echo'').then(data => { assert.equal(data.echo, ''ech0-t3st'', ''Test 2: the echo server is not working as expected'') }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/implement-a-root-level-request-logger-middleware.en.md b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/implement-a-root-level-request-logger-middleware.en.md index 234325a725..9332d69d9b 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/implement-a-root-level-request-logger-middleware.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/implement-a-root-level-request-logger-middleware.en.md @@ -24,8 +24,9 @@ Hint: Express evaluates functions in the order they appear in the code. This is
```yml -- text: Root level logger middleware should be active - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/root-middleware-logger'').then(data => { assert.isTrue(data.passed, ''root-level logger is not working as expected''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: Root level logger middleware should be active + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/root-middleware-logger'').then(data => { assert.isTrue(data.passed, ''root-level logger is not working as expected''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/meet-the-node-console.en.md b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/meet-the-node-console.en.md index 5faead997a..4558959994 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/meet-the-node-console.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/meet-the-node-console.en.md @@ -19,8 +19,9 @@ To get started, just print the classic "Hello World" in the console. We recommen
```yml -- text: "Hello World" should be in the console - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/hello-console'').then(data => { assert.isTrue(data.passed, ''"Hello World" is not in the server console''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: "Hello World" should be in the console + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/hello-console'').then(data => { assert.isTrue(data.passed, ''"Hello World" is not in the server console''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/serve-an-html-file.en.md b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/serve-an-html-file.en.md index 55eb90818c..dd10336f8d 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/serve-an-html-file.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/serve-an-html-file.en.md @@ -22,8 +22,9 @@ Note: You can edit the solution of the previous challenge, or create a new one.
```yml -- text: Your app should serve the file views/index.html - testString: 'getUserInput => $.get(getUserInput(''url'')).then(data => { assert.match(data, /

.*<\/h1>/, ''Your app does not serve the expected HTML''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: Your app should serve the file views/index.html + testString: 'getUserInput => $.get(getUserInput(''url'')).then(data => { assert.match(data, /

.*<\/h1>/, ''Your app does not serve the expected HTML''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/serve-json-on-a-specific-route.en.md b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/serve-json-on-a-specific-route.en.md index fca9160997..27f684f1ac 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/serve-json-on-a-specific-route.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/serve-json-on-a-specific-route.en.md @@ -20,8 +20,9 @@ Serve the object {"message": "Hello json"} as a response in JSON fo
```yml -- text: 'The endpoint /json should serve the json object {"message": "Hello json"}' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/json'').then(data => { assert.equal(data.message, ''Hello json'', ''The \''/json\'' endpoint does not serve the right data''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: 'The endpoint /json should serve the json object {"message": "Hello json"}' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/json'').then(data => { assert.equal(data.message, ''Hello json'', ''The \''/json\'' endpoint does not serve the right data''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/serve-static-assets.en.md b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/serve-static-assets.en.md index f301cd5d08..41af72c361 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/serve-static-assets.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/serve-static-assets.en.md @@ -20,8 +20,9 @@ Now your app should be able to serve a CSS stylesheet. From outside the public f
```yml -- text: Your app should serve asset files from the /public directory - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/style.css'').then(data => { assert.match(data, /body\s*\{[^\}]*\}/, ''Your app does not serve static assets''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: Your app should serve asset files from the /public directory + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/style.css'').then(data => { assert.match(data, /body\s*\{[^\}]*\}/, ''Your app does not serve static assets''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/start-a-working-express-server.en.md b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/start-a-working-express-server.en.md index c9fca5e28f..1c5ea7a70d 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/start-a-working-express-server.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/start-a-working-express-server.en.md @@ -23,8 +23,9 @@ Use the app.get() method to serve the string Hello Express, to GET
```yml -- text: Your app should serve the string 'Hello Express' - testString: 'getUserInput => $.get(getUserInput(''url'')).then(data => { assert.equal(data, ''Hello Express'', ''Your app does not serve the text "Hello Express"''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: Your app should serve the string 'Hello Express' + testString: 'getUserInput => $.get(getUserInput(''url'')).then(data => { assert.equal(data, ''Hello Express'', ''Your app does not serve the text "Hello Express"''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/use-body-parser-to-parse-post-requests.en.md b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/use-body-parser-to-parse-post-requests.en.md index 965bd00f27..7f64a1c044 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/use-body-parser-to-parse-post-requests.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/use-body-parser-to-parse-post-requests.en.md @@ -25,8 +25,9 @@ The middleware to handle url encoded data is returned by bodyParser.urlenc
```yml -- text: The 'body-parser' middleware should be mounted - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/add-body-parser'').then(data => { assert.isAbove(data.mountedAt, 0, ''"body-parser" is not mounted correctly'') }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: The 'body-parser' middleware should be mounted + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/add-body-parser'').then(data => { assert.isAbove(data.mountedAt, 0, ''"body-parser" is not mounted correctly'') }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/use-the-.env-file.en.md b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/use-the-.env-file.en.md index 8853f24acf..11771254cf 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/use-the-.env-file.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/use-the-.env-file.en.md @@ -20,8 +20,9 @@ Let's add an environment variable as a configuration option. Store the variable
```yml -- text: The response of the endpoint /json should change according to the environment variable MESSAGE_STYLE - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/use-env-vars'').then(data => { assert.isTrue(data.passed, ''The response of "/json" does not change according to MESSAGE_STYLE''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: The response of the endpoint /json should change according to the environment variable MESSAGE_STYLE + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/use-env-vars'').then(data => { assert.isTrue(data.passed, ''The response of "/json" does not change according to MESSAGE_STYLE''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/add-a-description-to-your-package.json.en.md b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/add-a-description-to-your-package.json.en.md index cd21814a9b..b87f6465ce 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/add-a-description-to-your-package.json.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/add-a-description-to-your-package.json.en.md @@ -24,8 +24,9 @@ Remember to use double-quotes for field-names (") and commas (,) to separate fie
```yml -- text: package.json should have a valid "description" key - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert(packJson.description, ''"description" is missing''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: package.json should have a valid "description" key + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert(packJson.description, ''"description" is missing''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/add-a-license-to-your-package.json.en.md b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/add-a-license-to-your-package.json.en.md index d619c2500f..aef3aa0512 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/add-a-license-to-your-package.json.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/add-a-license-to-your-package.json.en.md @@ -24,8 +24,9 @@ Fill the license-field in the package.json of your Glitch project as you find su
```yml -- text: package.json should have a valid "license" key - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert(packJson.license, ''"license" is missing''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: package.json should have a valid "license" key + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert(packJson.license, ''"license" is missing''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/add-a-version-to-your-package.json.en.md b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/add-a-version-to-your-package.json.en.md index fdcb8bcee3..d68b8964c7 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/add-a-version-to-your-package.json.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/add-a-version-to-your-package.json.en.md @@ -22,8 +22,9 @@ Add a version to the package.json in your Glitch project.
```yml -- text: package.json should have a valid "version" key - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert(packJson.version, ''"version" is missing''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: package.json should have a valid "version" key + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert(packJson.version, ''"version" is missing''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/add-keywords-to-your-package.json.en.md b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/add-keywords-to-your-package.json.en.md index f20573d473..b370a65fd8 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/add-keywords-to-your-package.json.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/add-keywords-to-your-package.json.en.md @@ -24,12 +24,13 @@ One of the keywords should be freecodecamp.
```yml -- text: package.json should have a valid "keywords" key - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert(packJson.keywords, ''"keywords" is missing''); }, xhr => { throw new Error(xhr.responseText); })' -- text: '"keywords" field should be an Array' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.isArray(packJson.keywords, ''"keywords" is not an array''); }, xhr => { throw new Error(xhr.responseText); })' -- text: '"keywords" should include "freecodecamp"' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.include(packJson.keywords, ''freecodecamp'', ''"keywords" does not include "freecodecamp"''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: package.json should have a valid "keywords" key + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert(packJson.keywords, ''"keywords" is missing''); }, xhr => { throw new Error(xhr.responseText); })' + - text: '"keywords" field should be an Array' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.isArray(packJson.keywords, ''"keywords" is not an array''); }, xhr => { throw new Error(xhr.responseText); })' + - text: '"keywords" should include "freecodecamp"' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.include(packJson.keywords, ''freecodecamp'', ''"keywords" does not include "freecodecamp"''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/expand-your-project-with-external-packages-from-npm.en.md b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/expand-your-project-with-external-packages-from-npm.en.md index a0b875aeed..3125f0eb13 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/expand-your-project-with-external-packages-from-npm.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/expand-your-project-with-external-packages-from-npm.en.md @@ -26,10 +26,11 @@ Moment is a handy library for working with time and dates.
```yml -- text: '"dependencies" should include "moment"' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, ''moment'', ''"dependencies" does not include "moment"''); }, xhr => { throw new Error(xhr.responseText); })' -- text: '"moment" version should be "2.14.0"' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.match(packJson.dependencies.moment, /^[\^\~]?2\.14\.0/, ''Wrong version of "moment" installed. It should be 2.14.0''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: '"dependencies" should include "moment"' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, ''moment'', ''"dependencies" does not include "moment"''); }, xhr => { throw new Error(xhr.responseText); })' + - text: '"moment" version should be "2.14.0"' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.match(packJson.dependencies.moment, /^[\^\~]?2\.14\.0/, ''Wrong version of "moment" installed. It should be 2.14.0''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/how-to-use-package.json-the-core-of-any-node.js-project-or-npm-package.en.md b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/how-to-use-package.json-the-core-of-any-node.js-project-or-npm-package.en.md index 1eb890618e..c2c9ffd287 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/how-to-use-package.json-the-core-of-any-node.js-project-or-npm-package.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/how-to-use-package.json-the-core-of-any-node.js-project-or-npm-package.en.md @@ -27,8 +27,9 @@ All fields must be separated with a comma (,)
```yml -- text: package.json should have a valid "author" key - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert(packJson.author, ''"author" is missing''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: package.json should have a valid "author" key + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert(packJson.author, ''"author" is missing''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/manage-npm-dependencies-by-understanding-semantic-versioning.en.md b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/manage-npm-dependencies-by-understanding-semantic-versioning.en.md index 977ef38d2d..4b40bdcea5 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/manage-npm-dependencies-by-understanding-semantic-versioning.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/manage-npm-dependencies-by-understanding-semantic-versioning.en.md @@ -31,10 +31,11 @@ In the dependencies-section of your package.json, change the version of moment t
```yml -- text: '"dependencies" should include "moment"' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, ''moment'', ''"dependencies" does not include "moment"''); }, xhr => { throw new Error(xhr.responseText); })' -- text: '"moment" version should be "2.10.2"' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.match(packJson.dependencies.moment, /^[\^\~]?2\.10\.2/, ''Wrong version of "moment". It should be 2.10.2''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: '"dependencies" should include "moment"' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, ''moment'', ''"dependencies" does not include "moment"''); }, xhr => { throw new Error(xhr.responseText); })' + - text: '"moment" version should be "2.10.2"' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.match(packJson.dependencies.moment, /^[\^\~]?2\.10\.2/, ''Wrong version of "moment". It should be 2.10.2''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/remove-a-package-from-your-dependencies.en.md b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/remove-a-package-from-your-dependencies.en.md index c8a8714d07..b651da261b 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/remove-a-package-from-your-dependencies.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/remove-a-package-from-your-dependencies.en.md @@ -23,8 +23,9 @@ Make sure you have the right amount of commas after removing it.
```yml -- text: '"dependencies" should not include "moment"' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.notProperty(packJson.dependencies, ''moment'', ''"dependencies" still includes "moment"''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: '"dependencies" should not include "moment"' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.notProperty(packJson.dependencies, ''moment'', ''"dependencies" still includes "moment"''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/use-the-caret-character-to-use-the-latest-minor-version-of-a-dependency.en.md b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/use-the-caret-character-to-use-the-latest-minor-version-of-a-dependency.en.md index c52f78948a..34fe484428 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/use-the-caret-character-to-use-the-latest-minor-version-of-a-dependency.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/use-the-caret-character-to-use-the-latest-minor-version-of-a-dependency.en.md @@ -24,10 +24,11 @@ Note that the version numbers themselves not should be changed.
```yml -- text: '"dependencies" should include "moment"' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, ''moment'', ''"dependencies" does not include "moment"''); }, xhr => { throw new Error(xhr.responseText); })' -- text: '"moment" version should match "^2.x.x"' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.match(packJson.dependencies.moment, /^\^2\./, ''Wrong version of "moment". It should be ^2.10.2''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: '"dependencies" should include "moment"' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, ''moment'', ''"dependencies" does not include "moment"''); }, xhr => { throw new Error(xhr.responseText); })' + - text: '"moment" version should match "^2.x.x"' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.match(packJson.dependencies.moment, /^\^2\./, ''Wrong version of "moment". It should be ^2.10.2''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/use-the-tilde-character-to-always-use-the-latest-patch-version-of-a-dependency.en.md b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/use-the-tilde-character-to-always-use-the-latest-patch-version-of-a-dependency.en.md index 633e4c1082..275713cf8a 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/use-the-tilde-character-to-always-use-the-latest-patch-version-of-a-dependency.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/managing-packages-with-npm/use-the-tilde-character-to-always-use-the-latest-patch-version-of-a-dependency.en.md @@ -24,10 +24,11 @@ Note that the version numbers themselves not should be changed.
```yml -- text: '"dependencies" should include "moment"' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, ''moment'', ''"dependencies" does not include "moment"''); }, xhr => { throw new Error(xhr.responseText); })' -- text: '"moment" version should match "~2.10.2"' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.match(packJson.dependencies.moment, /^\~2\.10\.2/, ''Wrong version of "moment". It should be ~2.10.2''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: '"dependencies" should include "moment"' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, ''moment'', ''"dependencies" does not include "moment"''); }, xhr => { throw new Error(xhr.responseText); })' + - text: '"moment" version should match "~2.10.2"' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.match(packJson.dependencies.moment, /^\~2\.10\.2/, ''Wrong version of "moment". It should be ~2.10.2''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/chain-search-query-helpers-to-narrow-search-results.en.md b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/chain-search-query-helpers-to-narrow-search-results.en.md index e6562f744e..c37e4bb9dc 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/chain-search-query-helpers-to-narrow-search-results.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/chain-search-query-helpers-to-narrow-search-results.en.md @@ -19,8 +19,9 @@ Find people who like "burrito". Sort them by name, limit the results to two docu
```yml -- text: Chaining query helpers should succeed - testString: 'getUserInput => $.ajax({url: getUserInput(''url'') + ''/_api/query-tools'', type: ''POST'', contentType:''application/json'', data: JSON.stringify([{name: ''Pablo'', age: 26, favoriteFoods: [''burrito'', ''hot-dog'']}, {name: ''Bob'', age: 23, favoriteFoods: [''pizza'', ''nachos'']}, {name: ''Ashley'', age: 32, favoriteFoods: [''steak'', ''burrito'']}, {name: ''Mario'', age: 51, favoriteFoods: [''burrito'', ''prosciutto'']} ]) }).then(data => { assert.isArray(data, ''the response should be an Array''); assert.equal(data.length, 2, ''the data array length is not what expected''); assert.notProperty(data[0], ''age'', ''The returned first item has too many properties''); assert.equal(data[0].name, ''Ashley'', ''The returned first item name is not what expected''); assert.notProperty(data[1], ''age'', ''The returned second item has too many properties''); assert.equal(data[1].name, ''Mario'', ''The returned second item name is not what expected'');}, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: Chaining query helpers should succeed + testString: 'getUserInput => $.ajax({url: getUserInput(''url'') + ''/_api/query-tools'', type: ''POST'', contentType:''application/json'', data: JSON.stringify([{name: ''Pablo'', age: 26, favoriteFoods: [''burrito'', ''hot-dog'']}, {name: ''Bob'', age: 23, favoriteFoods: [''pizza'', ''nachos'']}, {name: ''Ashley'', age: 32, favoriteFoods: [''steak'', ''burrito'']}, {name: ''Mario'', age: 51, favoriteFoods: [''burrito'', ''prosciutto'']} ]) }).then(data => { assert.isArray(data, ''the response should be an Array''); assert.equal(data.length, 2, ''the data array length is not what expected''); assert.notProperty(data[0], ''age'', ''The returned first item has too many properties''); assert.equal(data[0].name, ''Ashley'', ''The returned first item name is not what expected''); assert.notProperty(data[1], ''age'', ''The returned second item has too many properties''); assert.equal(data[1].name, ''Mario'', ''The returned second item name is not what expected'');}, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/create-a-model.en.md b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/create-a-model.en.md index 96d8eba69d..f9aa8d9e10 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/create-a-model.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/create-a-model.en.md @@ -38,8 +38,9 @@ Warning - When interacting with remote services, errors may occur !
```yml -- text: Creating an instance from a mongoose schema should succeed - testString: 'getUserInput => $.post(getUserInput(''url'') + ''/_api/mongoose-model'', {name: ''Mike'', age: 28, favoriteFoods: [''pizza'', ''cheese'']}).then(data => { assert.equal(data.name, ''Mike'', ''"model.name" is not what expected''); assert.equal(data.age, ''28'', ''"model.age" is not what expected''); assert.isArray(data.favoriteFoods, ''"model.favoriteFoods" is not an Array''); assert.include(data.favoriteFoods, ''pizza'', ''"model.favoriteFoods" does not include the expected items''); assert.include(data.favoriteFoods, ''cheese'', ''"model.favoriteFoods" does not include the expected items''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: Creating an instance from a mongoose schema should succeed + testString: 'getUserInput => $.post(getUserInput(''url'') + ''/_api/mongoose-model'', {name: ''Mike'', age: 28, favoriteFoods: [''pizza'', ''cheese'']}).then(data => { assert.equal(data.name, ''Mike'', ''"model.name" is not what expected''); assert.equal(data.age, ''28'', ''"model.age" is not what expected''); assert.isArray(data.favoriteFoods, ''"model.favoriteFoods" is not an Array''); assert.include(data.favoriteFoods, ''pizza'', ''"model.favoriteFoods" does not include the expected items''); assert.include(data.favoriteFoods, ''cheese'', ''"model.favoriteFoods" does not include the expected items''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/create-and-save-a-record-of-a-model.en.md b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/create-and-save-a-record-of-a-model.en.md index a3fa4d140a..b5ca8a3e6a 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/create-and-save-a-record-of-a-model.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/create-and-save-a-record-of-a-model.en.md @@ -23,8 +23,9 @@ Create a document instance using the Person constructor you build before. Pass t
```yml -- text: Creating and saving a db item should succeed - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/create-and-save-person'').then(data => { assert.isString(data.name, ''"item.name" should be a String''); assert.isNumber(data.age, ''28'', ''"item.age" should be a Number''); assert.isArray(data.favoriteFoods, ''"item.favoriteFoods" should be an Array''); assert.equal(data.__v, 0, ''The db item should be not previously edited''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: Creating and saving a db item should succeed + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/create-and-save-person'').then(data => { assert.isString(data.name, ''"item.name" should be a String''); assert.isNumber(data.age, ''28'', ''"item.age" should be a Number''); assert.isArray(data.favoriteFoods, ''"item.favoriteFoods" should be an Array''); assert.equal(data.__v, 0, ''The db item should be not previously edited''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/create-many-records-with-model.create.en.md b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/create-many-records-with-model.create.en.md index 9203ef3c03..367d5634c2 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/create-many-records-with-model.create.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/create-many-records-with-model.create.en.md @@ -18,8 +18,9 @@ Sometimes you need to create many instances of your models, e.g. when seeding a
```yml -- text: Creating many db items at once should succeed - testString: 'getUserInput => $.ajax({url: getUserInput(''url'') + ''/_api/create-many-people'', type: ''POST'', contentType:''application/json'', data: JSON.stringify([{name: ''John'', age: 24, favoriteFoods: [''pizza'', ''salad'']}, {name: ''Mary'', age: 21, favoriteFoods: [''onions'', ''chicken'']}])}).then(data => { assert.isArray(data, ''the response should be an array''); assert.equal(data.length, 2, ''the response does not contain the expected number of items''); assert.equal(data[0].name, ''John'', ''The first item is not correct''); assert.equal(data[0].__v, 0, ''The first item should be not previously edited''); assert.equal(data[1].name, ''Mary'', ''The second item is not correct''); assert.equal(data[1].__v, 0, ''The second item should be not previously edited''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: Creating many db items at once should succeed + testString: 'getUserInput => $.ajax({url: getUserInput(''url'') + ''/_api/create-many-people'', type: ''POST'', contentType:''application/json'', data: JSON.stringify([{name: ''John'', age: 24, favoriteFoods: [''pizza'', ''salad'']}, {name: ''Mary'', age: 21, favoriteFoods: [''onions'', ''chicken'']}])}).then(data => { assert.isArray(data, ''the response should be an array''); assert.equal(data.length, 2, ''the response does not contain the expected number of items''); assert.equal(data[0].name, ''John'', ''The first item is not correct''); assert.equal(data[0].__v, 0, ''The first item should be not previously edited''); assert.equal(data[1].name, ''Mary'', ''The second item is not correct''); assert.equal(data[1].__v, 0, ''The second item should be not previously edited''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/delete-many-documents-with-model.remove.en.md b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/delete-many-documents-with-model.remove.en.md index 3e9e46f0a5..9c363b6f10 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/delete-many-documents-with-model.remove.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/delete-many-documents-with-model.remove.en.md @@ -19,8 +19,9 @@ Note: Model.remove() doesn’t return the deleted document, but a JSON object co
```yml -- text: Deleting many items at once should succeed - testString: 'getUserInput => $.ajax({url: getUserInput(''url'') + ''/_api/remove-many-people'', type: ''POST'', contentType:''application/json'', data: JSON.stringify([{name: ''Mary'', age: 16, favoriteFoods: [''lollipop'']}, {name: ''Mary'', age: 21, favoriteFoods: [''steak'']}])}).then(data => { assert.isTrue(!!data.ok, ''The mongo stats are not what expected''); assert.equal(data.n, 2, ''The number of items affected is not what expected''); assert.equal(data.count, 0, ''the db items count is not what expected''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: Deleting many items at once should succeed + testString: 'getUserInput => $.ajax({url: getUserInput(''url'') + ''/_api/remove-many-people'', type: ''POST'', contentType:''application/json'', data: JSON.stringify([{name: ''Mary'', age: 16, favoriteFoods: [''lollipop'']}, {name: ''Mary'', age: 21, favoriteFoods: [''steak'']}])}).then(data => { assert.isTrue(!!data.ok, ''The mongo stats are not what expected''); assert.equal(data.n, 2, ''The number of items affected is not what expected''); assert.equal(data.count, 0, ''the db items count is not what expected''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/delete-one-document-using-model.findbyidandremove.en.md b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/delete-one-document-using-model.findbyidandremove.en.md index 6c6a27c9bb..10dc2e7243 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/delete-one-document-using-model.findbyidandremove.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/delete-one-document-using-model.findbyidandremove.en.md @@ -18,8 +18,9 @@ Delete one person by her _id. You should use one of the methods findByIdAndRemov
```yml -- text: Deleting an item should succeed - testString: 'getUserInput => $.post(getUserInput(''url'') + ''/_api/remove-one-person'', {name:''Jason Bourne'', age: 36, favoriteFoods:[''apples'']}).then(data => { assert.equal(data.name, ''Jason Bourne'', ''item.name is not what expected''); assert.equal(data.age, 36, ''item.age is not what expected''); assert.deepEqual(data.favoriteFoods, [''apples''], ''item.favoriteFoods is not what expected''); assert.equal(data.__v, 0); assert.equal(data.count, 0, ''the db items count is not what expected''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: Deleting an item should succeed + testString: 'getUserInput => $.post(getUserInput(''url'') + ''/_api/remove-one-person'', {name:''Jason Bourne'', age: 36, favoriteFoods:[''apples'']}).then(data => { assert.equal(data.name, ''Jason Bourne'', ''item.name is not what expected''); assert.equal(data.age, 36, ''item.age is not what expected''); assert.deepEqual(data.favoriteFoods, [''apples''], ''item.favoriteFoods is not what expected''); assert.equal(data.__v, 0); assert.equal(data.count, 0, ''the db items count is not what expected''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/install-and-set-up-mongoose.en.md b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/install-and-set-up-mongoose.en.md index 6e0d55bf74..e2434ac71f 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/install-and-set-up-mongoose.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/install-and-set-up-mongoose.en.md @@ -18,12 +18,13 @@ Add mongodb and mongoose to the project’s package.json. Then require mongoose.
```yml -- text: '"mongodb" dependency should be in package.json' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/file/package.json'').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, ''mongodb''); }, xhr => { throw new Error(xhr.responseText); })' -- text: '"mongoose" dependency should be in package.json' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/file/package.json'').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, ''mongoose''); }, xhr => { throw new Error(xhr.responseText); })' -- text: '"mongoose" should be connected to a database' - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/is-mongoose-ok'').then(data => {assert.isTrue(data.isMongooseOk, ''mongoose is not connected'')}, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: '"mongodb" dependency should be in package.json' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/file/package.json'').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, ''mongodb''); }, xhr => { throw new Error(xhr.responseText); })' + - text: '"mongoose" dependency should be in package.json' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/file/package.json'').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, ''mongoose''); }, xhr => { throw new Error(xhr.responseText); })' + - text: '"mongoose" should be connected to a database' + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/is-mongoose-ok'').then(data => {assert.isTrue(data.isMongooseOk, ''mongoose is not connected'')}, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/perform-classic-updates-by-running-find-edit-then-save.en.md b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/perform-classic-updates-by-running-find-edit-then-save.en.md index 7c7bd41962..6f117b1a6a 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/perform-classic-updates-by-running-find-edit-then-save.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/perform-classic-updates-by-running-find-edit-then-save.en.md @@ -20,8 +20,9 @@ Find a person by _id ( use any of the above methods ) with the parameter personI
```yml -- text: Find-edit-update an item should succeed - testString: 'getUserInput => $.post(getUserInput(''url'') + ''/_api/find-edit-save'', {name:''Poldo'', age: 40, favoriteFoods:[''spaghetti'']}).then(data => { assert.equal(data.name, ''Poldo'', ''item.name is not what expected''); assert.equal(data.age, 40, ''item.age is not what expected''); assert.deepEqual(data.favoriteFoods, [''spaghetti'', ''hamburger''], ''item.favoriteFoods is not what expected''); assert.equal(data.__v, 1, ''The item should be previously edited''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: Find-edit-update an item should succeed + testString: 'getUserInput => $.post(getUserInput(''url'') + ''/_api/find-edit-save'', {name:''Poldo'', age: 40, favoriteFoods:[''spaghetti'']}).then(data => { assert.equal(data.name, ''Poldo'', ''item.name is not what expected''); assert.equal(data.age, 40, ''item.age is not what expected''); assert.deepEqual(data.favoriteFoods, [''spaghetti'', ''hamburger''], ''item.favoriteFoods is not what expected''); assert.equal(data.__v, 1, ''The item should be previously edited''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/perform-new-updates-on-a-document-using-model.findoneandupdate.en.md b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/perform-new-updates-on-a-document-using-model.findoneandupdate.en.md index 47387d0004..58d37ea5df 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/perform-new-updates-on-a-document-using-model.findoneandupdate.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/perform-new-updates-on-a-document-using-model.findoneandupdate.en.md @@ -20,8 +20,9 @@ Hint: We want you to return the updated document. To do that you need to pass th
```yml -- text: findOneAndUpdate an item should succeed - testString: 'getUserInput => $.post(getUserInput(''url'') + ''/_api/find-one-update'', {name:''Dorian Gray'', age: 35, favoriteFoods:[''unknown'']}).then(data => { assert.equal(data.name, ''Dorian Gray'', ''item.name is not what expected''); assert.equal(data.age, 20, ''item.age is not what expected''); assert.deepEqual(data.favoriteFoods, [''unknown''], ''item.favoriteFoods is not what expected''); assert.equal(data.__v, 0, ''findOneAndUpdate does not increment version by design !!!''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: findOneAndUpdate an item should succeed + testString: 'getUserInput => $.post(getUserInput(''url'') + ''/_api/find-one-update'', {name:''Dorian Gray'', age: 35, favoriteFoods:[''unknown'']}).then(data => { assert.equal(data.name, ''Dorian Gray'', ''item.name is not what expected''); assert.equal(data.age, 20, ''item.age is not what expected''); assert.deepEqual(data.favoriteFoods, [''unknown''], ''item.favoriteFoods is not what expected''); assert.equal(data.__v, 0, ''findOneAndUpdate does not increment version by design !!!''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/use-model.find-to-search-your-database.en.md b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/use-model.find-to-search-your-database.en.md index 79afbd12cc..03e13a2043 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/use-model.find-to-search-your-database.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/use-model.find-to-search-your-database.en.md @@ -19,8 +19,9 @@ In its simplest usage, Model.find() accepts a query document (a JSON object ) as
```yml -- text: Find all items corresponding to a criteria should succeed - testString: 'getUserInput => $.post(getUserInput(''url'') + ''/_api/find-all-by-name'', {name: ''r@nd0mN4m3'', age: 24, favoriteFoods: [''pizza'']}).then(data => { assert.isArray(data, ''the response should be an Array''); assert.equal(data[0].name, ''r@nd0mN4m3'', ''item.name is not what expected''); assert.equal(data[0].__v, 0, ''The item should be not previously edited''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: Find all items corresponding to a criteria should succeed + testString: 'getUserInput => $.post(getUserInput(''url'') + ''/_api/find-all-by-name'', {name: ''r@nd0mN4m3'', age: 24, favoriteFoods: [''pizza'']}).then(data => { assert.isArray(data, ''the response should be an Array''); assert.equal(data[0].name, ''r@nd0mN4m3'', ''item.name is not what expected''); assert.equal(data[0].__v, 0, ''The item should be not previously edited''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/use-model.findbyid-to-search-your-database-by-id.en.md b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/use-model.findbyid-to-search-your-database-by-id.en.md index ae5ace9ce0..41d8b0c31b 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/use-model.findbyid-to-search-your-database-by-id.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/use-model.findbyid-to-search-your-database-by-id.en.md @@ -18,8 +18,9 @@ When saving a document, mongodb automatically adds the field _id, and set it to
```yml -- text: Find an item by Id should succeed - testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/find-by-id'').then(data => { assert.equal(data.name, ''test'', ''item.name is not what expected''); assert.equal(data.age, 0, ''item.age is not what expected''); assert.deepEqual(data.favoriteFoods, [''none''], ''item.favoriteFoods is not what expected''); assert.equal(data.__v, 0, ''The item should be not previously edited''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: Find an item by Id should succeed + testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/find-by-id'').then(data => { assert.equal(data.name, ''test'', ''item.name is not what expected''); assert.equal(data.age, 0, ''item.age is not what expected''); assert.deepEqual(data.favoriteFoods, [''none''], ''item.favoriteFoods is not what expected''); assert.equal(data.__v, 0, ''The item should be not previously edited''); }, xhr => { throw new Error(xhr.responseText); })' ``` diff --git a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/use-model.findone-to-return-a-single-matching-document-from-your-database.en.md b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/use-model.findone-to-return-a-single-matching-document-from-your-database.en.md index 4cfdf53bc7..ec0d5c1e3c 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/use-model.findone-to-return-a-single-matching-document-from-your-database.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/use-model.findone-to-return-a-single-matching-document-from-your-database.en.md @@ -18,8 +18,9 @@ Model.findOne() behaves like .find(), but it returns only one document (not an a
```yml -- text: Find one item should succeed - testString: 'getUserInput => $.post(getUserInput(''url'') + ''/_api/find-one-by-food'', {name: ''Gary'', age: 46, favoriteFoods: [''chicken salad'']}).then(data => { assert.equal(data.name, ''Gary'', ''item.name is not what expected''); assert.deepEqual(data.favoriteFoods, [''chicken salad''], ''item.favoriteFoods is not what expected''); assert.equal(data.__v, 0, ''The item should be not previously edited''); }, xhr => { throw new Error(xhr.responseText); })' +tests: + - text: Find one item should succeed + testString: 'getUserInput => $.post(getUserInput(''url'') + ''/_api/find-one-by-food'', {name: ''Gary'', age: 46, favoriteFoods: [''chicken salad'']}).then(data => { assert.equal(data.name, ''Gary'', ''item.name is not what expected''); assert.deepEqual(data.favoriteFoods, [''chicken salad''], ''item.favoriteFoods is not what expected''); assert.equal(data.__v, 0, ''The item should be not previously edited''); }, xhr => { throw new Error(xhr.responseText); })' ```