-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
include a final solution exercise 05
- Loading branch information
Showing
4 changed files
with
3,653 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
node-dependencies/5-final-solution-exercise-dependency/__tests__/address-parser.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const { parse } = require('../address-parser'); | ||
|
||
describe('Address Parser', () => { | ||
describe('Address parser', () => { | ||
test('should parse correctly', () => { | ||
expect(parse("I want to to order: 3 books to address: 112 street city here is my payment info: cardnumber") | ||
).toEqual({ | ||
order: "3 books", | ||
address: "112 street city", | ||
payment: "cardnumber", | ||
}); | ||
}) | ||
}) | ||
}) |
4 changes: 4 additions & 0 deletions
4
node-dependencies/5-final-solution-exercise-dependency/address-parser.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
exports.parse = function parseOrder(order) { | ||
const match = order.match(/order:\s(?<order>\w+\s\w+).*address:\s(?<address>\w+\s\w+\s\w+).*payment info:\s(?<payment>\w+)/) | ||
return match.groups; | ||
} |
Oops, something went wrong.