Skip to content

Commit

Permalink
feat(get-payload): added tests for .getPayload
Browse files Browse the repository at this point in the history
  • Loading branch information
maxprilutskiy committed Apr 6, 2020
1 parent f29aeb8 commit 3796b11
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
18 changes: 0 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
# 1.0.0 (2020-04-06)


### Features

* **attach:** .attach produces new instance ([200d30b](https://github.com/prilutskiy/filterion/commit/200d30bc59cc8b00c9d15e3a02a4f699f0a6105d))
* **attach:** added .attach implementation ([e35f3c0](https://github.com/prilutskiy/filterion/commit/e35f3c00c326bcdd6179ffe141d2d27949cd3584))
* **Filterion:** Initial commit ([42a5438](https://github.com/prilutskiy/filterion/commit/42a5438292550ecacffa4c1d9887c52fe3e837b3))

# 1.0.0 (2020-04-06)


### Features

* **attach:** .attach produces new instance ([200d30b](https://github.com/prilutskiy/filterion/commit/200d30bc59cc8b00c9d15e3a02a4f699f0a6105d))
* **attach:** added .attach implementation ([e35f3c0](https://github.com/prilutskiy/filterion/commit/e35f3c00c326bcdd6179ffe141d2d27949cd3584))
* **Filterion:** Initial commit ([42a5438](https://github.com/prilutskiy/filterion/commit/42a5438292550ecacffa4c1d9887c52fe3e837b3))

# 1.0.0 (2020-04-03)


### Features

* **Filterion:** Initial commit ([42a5438](https://github.com/prilutskiy/filterion/commit/42a5438292550ecacffa4c1d9887c52fe3e837b3))
25 changes: 25 additions & 0 deletions src/Filterion.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,31 @@ describe('Filterion.isEmpty', () => {
});
});

describe('Filterion.getPayload', () => {
it('Newly created instance has empty payload', () => {
const expectedPayload = {};

const payload = new Filterion<MyTestFilter>()
.getPayload();

expect(payload).toStrictEqual(expectedPayload);
});
it('Payload has valid format', () => {
const expectedPayload = {
name: { '=': ['Max'] },
age: { '>': [0], '<': [100] },
};

const payload = new Filterion<MyTestFilter>()
.add('name', 'Max')
.add('age', 0, '>')
.add('age', 100, '<')
.getPayload();

expect(payload).toStrictEqual(expectedPayload);
});
});

type MyTestFilter = {
name: string;
age: number;
Expand Down

0 comments on commit 3796b11

Please sign in to comment.