Skip to content

Commit

Permalink
Merge pull request #5 from homer0/next
Browse files Browse the repository at this point in the history
v1.0.1
  • Loading branch information
homer0 committed Sep 12, 2019
2 parents a457ebe + 35df057 commit 50980c3
Show file tree
Hide file tree
Showing 5 changed files with 195 additions and 113 deletions.
13 changes: 13 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### What does this PR do?

### How should it be tested manually?

```bash
yarn test
# or
npm test
```

### Are there any related PRs?

### TODOs
15 changes: 11 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@
"name": "parserror",
"description": "Parse errors and generate more human messages",
"homepage": "https://homer0.github.io/parserror/",
"version": "1.0.0",
"version": "1.0.1",
"repository": "homer0/parserror",
"author": "Leonardo Apiwan (@homer0) <me@homer0.com>",
"license": "MIT",
"keywords": [
"parse",
"error",
"errors",
"normalize",
"format"
],
"dependencies": {},
"devDependencies": {
"@babel/preset-env": "7.5.5",
"@babel/core": "7.5.5",
"@babel/plugin-transform-runtime": "7.5.5",
"@babel/preset-env": "7.6.0",
"@babel/core": "7.6.0",
"@babel/plugin-transform-runtime": "7.6.0",
"coveralls": "^3.0.6",
"esdoc": "^1.1.0",
"esdoc-standard-plugin": "^1.0.0",
Expand Down
7 changes: 7 additions & 0 deletions src/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ class Scope {

return theCase || null;
}
/**
* Returns all available cases for this scope.
* @return {Array<ErrorCase>}
*/
getCases() {
return this._cases;
}
/**
* Checks whether or not there's a case based on its name.
* @param {String} name The case's name.
Expand Down
25 changes: 25 additions & 0 deletions tests/scope.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,31 @@ describe('Scope', () => {
expect(result).toBe(myCase);
});

it('should return all saved cases', () => {
// Given
class MyCase extends ErrorCase {}
const myFirstCase = new MyCase({
name: 'nameOne',
condition: 'conditionOne',
message: 'messageOne',
});
const mySecondCase = new MyCase({
name: 'nameTwo',
condition: 'conditionTwo',
message: 'messageTwo',
});
let sut = null;
let result = null;
// When
sut = new Scope('myScope');
sut
.addCase(myFirstCase)
.addCase(mySecondCase);
result = sut.getCases();
// Then
expect(result).toEqual([myFirstCase, mySecondCase]);
});

it('should remove a saved case by its name', () => {
// Given
class MyCase extends ErrorCase {}
Expand Down

0 comments on commit 50980c3

Please sign in to comment.