-
Notifications
You must be signed in to change notification settings - Fork 3
Improvement: Modernize #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
c6c6f44
Migrate to pnpm and upgrade lerna
leoeuclids 2e61053
Adds push and update to relation
leoeuclids d2a879e
Make delete accept identifiers or an object
leoeuclids 7078a6b
Rename relation serialize to normalize and add tests
leoeuclids 4f93eee
Use pnpm for package json scripts
leoeuclids 805b27a
Adds push, update and new way of calling delete to the readme
leoeuclids 04e1166
Add GitHub action configuration
benedikt 9c0c81a
Adds missing relationship resource
benedikt d1ec3af
Add message resource
benedikt 2556feb
Allow request bodies for DELETE requests
benedikt 2b80e12
Add sections about new resources to the README
benedikt 4497fc7
Use import instead of require
benedikt 277659a
Handle normalization on a resource level
benedikt 14b51a9
Add more attribute validations
benedikt 5a3a798
Adds prettier
leoeuclids a5f3dba
Add linting as a step in GitHub Actions
benedikt 48ff6fa
Update various GitHub links
benedikt 0818a8f
Upgrade to rollup@4
leoeuclids c1d11f3
Upgrades test packages
leoeuclids ab55333
Fix eslint on widget
leoeuclids File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,8 +1,4 @@ | ||
| { | ||
| "packages": [ | ||
| "packages/*" | ||
| ], | ||
| "version": "independent", | ||
| "npmClient": "yarn", | ||
| "useWorkspaces": true | ||
| "npmClient": "pnpm" | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -1,52 +1,131 @@ | ||
| import { expect, use } from 'chai'; | ||
| import { createStubInstance } from 'sinon'; | ||
| import sinonChai from 'sinon-chai'; | ||
| import { expect, use } from "chai"; | ||
| import { createStubInstance } from "sinon"; | ||
| import sinonChai from "sinon-chai"; | ||
|
|
||
| use(sinonChai); | ||
|
|
||
| import Relation from '../src/relation'; | ||
| import User from '../src/user'; | ||
| import Client from '../src/client'; | ||
| import Relation from "../src/relation"; | ||
| import User from "../src/user"; | ||
| import Client from "../src/client"; | ||
|
|
||
| describe('Relation', function() { | ||
| describe("Relation", function () { | ||
| let resource = User; | ||
| let scope = {}; | ||
|
|
||
| let relation; | ||
| let client; | ||
|
|
||
| beforeEach(function() { | ||
| beforeEach(function () { | ||
| client = createStubInstance(Client); | ||
| scope.client = client; | ||
|
|
||
| relation = new Relation(scope, resource); | ||
| }); | ||
|
|
||
| it('should throw the resource\'s validation errors', function() { | ||
| expect(function() { | ||
| it("should throw the resource's validation errors", function () { | ||
| expect(function () { | ||
| relation.create(); | ||
| }).to.throw('Missing required attributes object') | ||
| }).to.throw("Missing required attributes object"); | ||
| }); | ||
|
|
||
| describe('#create', function() { | ||
| describe("#create", function () { | ||
| let client = createStubInstance(Client); | ||
|
|
||
| beforeEach(function() { | ||
| beforeEach(function () { | ||
| scope.client = client; | ||
| }); | ||
|
|
||
| it('should post the resource using the scope\'s client', function () { | ||
| relation.create({ identifier: '1' }); | ||
| it("should post the resource using the scope's client", function () { | ||
| relation.create({ | ||
| identifier: "1", | ||
| name: "John", | ||
| email: "john@userlist.com", | ||
| properties: { | ||
| foo: "bar", | ||
| bar: "baz", | ||
| }, | ||
| }); | ||
|
|
||
| expect(client.post).to.be.calledWithExactly('/users', new User({ identifier: '1' })); | ||
| expect(client.post).to.be.calledWithExactly( | ||
| "/users", | ||
| new User({ | ||
| identifier: "1", | ||
| name: "John", | ||
| email: "john@userlist.com", | ||
| properties: { | ||
| foo: "bar", | ||
| bar: "baz", | ||
| }, | ||
| }) | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('#delete', function() { | ||
| it('should delete the resource using the scope\'s client', function () { | ||
| relation.delete('1'); | ||
| describe("#push", function () { | ||
| let client = createStubInstance(Client); | ||
|
|
||
| beforeEach(function () { | ||
| scope.client = client; | ||
| }); | ||
|
|
||
| it("should post the resource using the scope's client", function () { | ||
| relation.push({ identifier: "1" }); | ||
|
|
||
| expect(client.post).to.be.calledWithExactly( | ||
| "/users", | ||
| new User({ identifier: "1" }) | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe("#update", function () { | ||
| let client = createStubInstance(Client); | ||
|
|
||
| beforeEach(function () { | ||
| scope.client = client; | ||
| }); | ||
|
|
||
| it("should post the resource using the scope's client", function () { | ||
| relation.update({ identifier: "1" }); | ||
|
|
||
| expect(client.post).to.be.calledWithExactly( | ||
| "/users", | ||
| new User({ identifier: "1" }) | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe("#delete", function () { | ||
| it("should delete the resource using the scope's client", function () { | ||
| relation.delete("1"); | ||
|
|
||
| expect(client.delete).to.be.calledWithExactly( | ||
| "/users", | ||
| new User({ identifier: "1" }) | ||
| ); | ||
| }); | ||
|
|
||
| it("should delete the resource using the scope's client", function () { | ||
| relation.delete({ identifier: "1", name: "John" }); | ||
|
|
||
| expect(client.delete).to.be.calledWithExactly( | ||
| "/users", | ||
| new User({ identifier: "1", name: "John" }) | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe("#normalize", function () { | ||
| it("should normalize a string into a new user object with an identifier", function () { | ||
| let normalized = relation.normalize("1"); | ||
|
|
||
| expect(normalized).to.be.eql(new User({ identifier: "1" })); | ||
| }); | ||
|
|
||
| it("should normalize an object into a new user with it's properties", function () { | ||
| let normalized = relation.normalize({ identifier: "1", name: "John" }); | ||
|
|
||
| expect(client.delete).to.be.calledWithExactly('/users/1'); | ||
| expect(normalized).to.be.eql(new User({ identifier: "1", name: "John" })); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.