Skip to content
This repository has been archived by the owner on May 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #100 from data-provider/release
Browse files Browse the repository at this point in the history
Release v3.0.0
  • Loading branch information
javierbrea committed Jan 9, 2021
2 parents cedb2f1 + 836b675 commit 2ab3482
Show file tree
Hide file tree
Showing 8 changed files with 395 additions and 661 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed
### Fixed
### Removed
### BREAKING CHANGES

## [3.0.0] - 2021-01-09

### Added
- chore: Add data-provider addons recommended tags to package.json

### Changed
- docs: Adapt docs to data-provider v3 API
- chore(deps): Update dependencies

### BREAKING CHANGES
- feat: Remove v2 compatibility

## [2.1.0] - 2021-01-07

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Memory origin addon for Data Provider

It provides CRUD methods for objects saved in memory.
It provides CRUD methods for objects stored in memory.

## Usage

Expand All @@ -27,7 +27,8 @@ When querying providers created with this addon, the query object can have one o
```javascript
import { Memory } from "@data-provider/memory";

const sessionStatus = new Memory("session-status", {
const sessionStatus = new Memory({
id: "session-status",
initialState: {
data: {
loggedIn: false
Expand Down
615 changes: 341 additions & 274 deletions package-lock.json

Large diffs are not rendered by default.

28 changes: 15 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"name": "@data-provider/memory",
"version": "2.1.0",
"version": "3.0.0",
"description": "Memory origin addon for Data Provider",
"keywords": [
"data-provider",
"data-provider-addon",
"data-provider-origin",
"addon",
"origin",
"data",
Expand Down Expand Up @@ -37,32 +39,32 @@
"test:mutation": "stryker run"
},
"peerDependencies": {
"@data-provider/core": ">=2.10.0"
"@data-provider/core": "3.x"
},
"devDependencies": {
"@babel/core": "7.12.10",
"@babel/preset-env": "7.12.10",
"@data-provider/core": "2.10.0",
"@babel/preset-env": "7.12.11",
"@data-provider/core": "3.0.0",
"@rollup/plugin-babel": "5.2.2",
"@rollup/plugin-commonjs": "17.0.0",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-node-resolve": "11.0.0",
"@stryker-mutator/core": "4.2.0",
"@stryker-mutator/jest-runner": "4.2.0",
"@rollup/plugin-node-resolve": "11.0.1",
"@stryker-mutator/core": "4.3.1",
"@stryker-mutator/jest-runner": "4.3.1",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "26.6.1",
"babel-polyfill": "6.26.0",
"eslint": "7.15.0",
"eslint-config-prettier": "7.0.0",
"eslint-plugin-prettier": "3.2.0",
"husky": "4.3.5",
"eslint": "7.17.0",
"eslint-config-prettier": "7.1.0",
"eslint-plugin-prettier": "3.3.1",
"husky": "4.3.7",
"jest": "26.6.3",
"lint-staged": "10.5.3",
"prettier": "2.2.1",
"redux": "4.0.5",
"rollup": "2.34.2",
"rollup": "2.36.1",
"rollup-plugin-terser": "7.0.2",
"sinon": "9.2.1"
"sinon": "9.2.3"
},
"lint-staged": {
"*.js": "eslint",
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sonar.organization=data-provider
sonar.projectKey=data-provider-memory
sonar.projectVersion=2.1.0
sonar.projectVersion=3.0.0

sonar.sources=src,test
sonar.exclusions=node_modules/**
Expand Down
7 changes: 3 additions & 4 deletions src/Memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/

import { Provider, providerArgsV3 } from "@data-provider/core";
import { Provider } from "@data-provider/core";

const TAG = "memory";

class Memory extends Provider {
constructor(...args) {
const [id, options, queryValue] = providerArgsV3(args);
super({ id, ...options }, queryValue);
constructor(options, queryValue) {
super(options, queryValue);
this._data = this.initialState.data;
this.options._data = this._options._data || this._data;
}
Expand Down
30 changes: 19 additions & 11 deletions test/memory.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ describe("Memory origin", () => {
};

beforeEach(() => {
userData = new Memory("foo-id", {
userData = new Memory({
id: "foo-id",
initialState: {
data: fooData,
},
Expand All @@ -117,7 +118,7 @@ describe("Memory origin", () => {

describe("without initialState", () => {
it("should return an empty object while resource is being loaded", () => {
userData = new Memory("foo-id-2");
userData = new Memory({ id: "foo-id-2" });
expect.assertions(2);
const promise = userData.read();
expect(userData.state.data).toEqual({});
Expand All @@ -141,7 +142,8 @@ describe("Memory origin", () => {
describe("when queried", () => {
it("should return default value correspondent to query while resource is being loaded", () => {
expect.assertions(2);
userData = new Memory("foo-id-2", {
userData = new Memory({
id: "foo-id-2",
initialState: {
data: fooData,
},
Expand Down Expand Up @@ -171,7 +173,8 @@ describe("Memory origin", () => {
foo: "foo-value",
};

userData = new Memory("foo-id", {
userData = new Memory({
id: "foo-id",
initialState: {
data: fooData,
},
Expand Down Expand Up @@ -257,7 +260,8 @@ describe("Memory origin", () => {
};

beforeEach(() => {
userData = new Memory("foo-id-2", {
userData = new Memory({
id: "foo-id-2",
initialState: {
data: fooData,
},
Expand Down Expand Up @@ -297,37 +301,40 @@ describe("Memory origin", () => {
describe("Instance id", () => {
it("should be assigned based on first argument", () => {
const FOO_ID = "foo-id";
const fooData = new Memory(FOO_ID);
const fooData = new Memory({ id: FOO_ID });
expect(providers.getById(FOO_ID).elements[0]).toEqual(fooData);
});
});

describe("Instance tags", () => {
describe("when no options are defined", () => {
it("should contain the memory tag", () => {
const fooData = new Memory("foo");
const fooData = new Memory({ id: "foo" });
expect(providers.getByTag("memory").elements[0]).toEqual(fooData);
});
});

describe("when passing options as second argument", () => {
it("should contain the memory tag even when a custom tag is received", () => {
const fooData = new Memory("foo", {
const fooData = new Memory({
id: "foo",
tags: ["foo-tag"],
});
expect(providers.getByTag("memory").elements[0]).toEqual(fooData);
});

it("should contain the memory tag even when an array of custom tags is received", () => {
const fooData = new Memory("foo", {
const fooData = new Memory({
id: "foo",
tags: ["foo-tag", "foo-tag-2"],
});
expect(providers.getByTag("memory").elements[0]).toEqual(fooData);
});

it("should contain defined custom tag if received", () => {
const FOO_TAG = "foo-tag";
const fooData = new Memory("foo", {
const fooData = new Memory({
id: "foo",
tags: [FOO_TAG],
});
expect(providers.getByTag(FOO_TAG).elements[0]).toEqual(fooData);
Expand All @@ -337,7 +344,8 @@ describe("Memory origin", () => {
expect.assertions(2);
const FOO_TAG = "foo-tag";
const FOO_TAG_2 = "foo-tag-2";
const fooData = new Memory("foo", {
const fooData = new Memory({
id: "foo",
tags: [FOO_TAG, FOO_TAG_2],
});
expect(providers.getByTag(FOO_TAG).elements[0]).toEqual(fooData);
Expand Down
Loading

0 comments on commit 2ab3482

Please sign in to comment.