Skip to content

Commit

Permalink
Merge pull request #81 from calluswhatyouwant/v0.5.x
Browse files Browse the repository at this point in the history
Upgrade to v0.5.2
  • Loading branch information
JoseRenan committed Oct 28, 2019
2 parents e7cc85a + 6e3ecdf commit 85a7624
Show file tree
Hide file tree
Showing 21 changed files with 892 additions and 191 deletions.
11 changes: 11 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Description

<!-- Place here a summary of the change and the issue fixed by it, its motivation and context. Don't forget to add "Fixes #(issue)" if it fixes an existing issue. -->

## Type of change

Please, add an X to each checkbox that applies to the changes made in this PR.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules/
.vscode/
build/
coverage/
.nyc_output/
package-lock.json
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.vscode/
src/
coverage/
.nyc_output/
test/
.prettierrc
.prettierignore
webpack.config.js
Expand Down
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.5.2] - 2019-10-27

### Added

- Instanbul CLI to generate test coverage reports.
- Create CHANGELOG, CONTRIBUTING and PR template.

### Changed

- Simplify tests for checking matching attributes between API responses and the objects generated from custom classes.
- Consider tests when linting.

### Fixed

- Fix a bug with the start/resume user playback request.

## [0.5.1] - 2019-10-02

### Fixed

- Fix a pagination bug when subsequent API calls are made.

### Security

- Update the versions of several dependencies.
35 changes: 35 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Contributing to spotify-web-sdk

So apparently you want to contribute with our project or you stumbled upon this file at random. Welcome, anyway!

Before anything else, please note that we have a [Code of Conduct](.github/CODE_OF_CONDUCT.md), which we expect to be strictly respected.

## Tests

Our tests are currently written with [nock](https://github.com/nock/nock) + [Chai](https://www.chaijs.com/) + [Mocha](https://mochajs.org/). All tests are placed under the `test` folder, and there is (or should be) one `name.test.ts` file for each `name.ts` file under the root of `src/lib`.

Our current implementation of tests uses nock for mocking HTTP request responses, so the tests work similarly. Reading one of them might be the best way to understand how the process works.

In the future, edge cases and other strategies should be considered to build a stronger test environment.

## Documentation

This project is still lacking a lot documentation-wise; we rely on the [Spotify Web API documentation](https://developer.spotify.com/documentation/web-api/), but we think it's important to bring it closer to the code in the near future.

## Implementation

Currently, we're successfully covering all possible endpoints in the Spotify Web API! However, we can certainly improve our code further!

## Styleguide

We use `tslint` to check if everything is tidy around here; because of `prettier`, which is run every time before a commit is completed, you shouldn't have to worry a lot about our styles. However, we encourage you to always write the best code you can!

Our continuous integration setup runs `tslint` and it'll break if there are remaining errors. Run `yarn lint` to check for errors and fix them before you send a PR!

## Creating a PR

We have a simple PR template that should appear once you create a PR. Try to be the most descriptive you can when creating your PR so that we have an easier and more complete overview of what you've made.

Be aware that all PRs should be made to the most recent version branch (currently, `v0.5.x`). Only the repository maintainers can send PRs straight to the `master` branch, as it reflects on the most recent version published to npm.

Thank you for contributing to our project!
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 calluswhatyouwant
Copyright (c) 2019 calluswhatyouwant

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ Even though I'm not certain you thought that right now, here's how to get starte

## Installation

Using Yarn:

```sh
yarn add spotify-web-sdk
```

Using NPM:

```sh
Expand Down Expand Up @@ -93,13 +99,11 @@ Please, note that we have a [Code of Conduct](.github/CODE_OF_CONDUCT.md), which

### Suggest a new feature or report a bug

Check our [issue templates](.github/ISSUE_TEMPLATE).
If you notice any other bugs or you have any ideas to improve our SDK, feel free to create an issue. We'll be more than happy to discuss it! Check our [issue templates](.github/ISSUE_TEMPLATE).

### Do it yourself

We're working on a CONTRIBUTING file and PR template.
In the meantime, you can already create PRs, especially to help us create the requests that are still missing and test the ones we have implemented.
Check [#21](/issues/21) for a list of GET endpoints we haven't got covered yet.
Check out our [CONTRIBUTING](./CONTRIBUTING.md) file!

### Maintainers

Expand All @@ -113,4 +117,4 @@ Made with [hall-of-fame](https://github.com/sourcerer-io/hall-of-fame).

## License

MIT
[MIT](./LICENSE)
21 changes: 18 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"Robson Junior <jrobsonjr16@gmail.com> (https://github.com/JRobsonJr)"
],
"license": "MIT",
"version": "0.3.0",
"version": "0.5.2",
"dependencies": {
"@types/lodash": "^4.14.121",
"axios": "^0.18.1",
Expand All @@ -19,8 +19,22 @@
"scripts": {
"start": "ts-node src/start.ts",
"build": "rimraf build && tsc && webpack",
"lint": "tslint -c tslint.json 'src/**/*.ts'",
"test": "mocha -r ts-node/register test/*.test.ts"
"lint": "tslint -c tslint.json 'src/**/*.ts' 'test/**/*.ts'",
"test": "mocha -r ts-node/register test/*.test.ts",
"test-with-coverage": "nyc --reporter=html mocha -r ts-node/register test/*.test.ts"
},
"nyc": {
"extension": [
".ts",
".tsx"
],
"exclude": [
"**/*.d.ts"
],
"reporter": [
"html"
],
"all": true
},
"husky": {
"hooks": {
Expand All @@ -40,6 +54,7 @@
"husky": "^1.1.2",
"mocha": "^5.2.0",
"nock": "^10.0.2",
"nyc": "^14.1.1",
"prettier": "^1.14.3",
"pretty-quick": "^1.8.0",
"rimraf": "^2.6.2",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const startUserPlayback = async (params?: {
positionMs?: number;
}) => {
const queryParams = propertiesToSnakeCase(_.pick(params, 'deviceId'));
const bodyParams = propertiesToSnakeCase(_.omit(params, 'deviceId'));
const bodyParams = propertiesToSnakeCase(_.omit(params, 'deviceId'), true);
const response = await getAxiosSpotifyInstance().put(
'/me/player/play',
bodyParams,
Expand Down
6 changes: 3 additions & 3 deletions test/albums.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import nock from 'nock';

import { albumMock, AlbumMock } from './mocks/albums/album.mock';
import { albumMock } from './mocks/albums/album.mock';
import { severalAlbumsMock } from './mocks/albums/several-albums.mock';
import { albumTracksMock } from './mocks/albums/album-tracks.mock';
import {
Expand Down Expand Up @@ -53,9 +53,9 @@ describe('Album requests', () => {
'3dB0bCgmpEgCSr3aU1bOtv',
]);

for (let i = 0; i < severalAlbumsResponse.length; i++) {
for (let i = 0; i < severalAlbumsResponse.length; i += 1) {
const albumResponse: Album = severalAlbumsResponse[i];
const albumMock: AlbumMock = severalAlbumsMock.albums[i];
const albumMock: any = severalAlbumsMock.albums[i];
checkMatchingAlbumAttributes(albumResponse, albumMock);
}
});
Expand Down
18 changes: 7 additions & 11 deletions test/artists.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import nock from 'nock';

import { artistMock, ArtistMock } from './mocks/artists/artist.mock';
import { artistMock } from './mocks/artists/artist.mock';
import { severalArtistsMock } from './mocks/artists/several-artists.mock';
import { artistAlbumsMock } from './mocks/artists/artist-albums.mock';
import { artistRelatedArtistsMock } from './mocks/artists/artist-related-artists.mock';
import {
artistTopTracksMock,
TrackMock,
} from './mocks/artists/artist-top-tracks.mock';
import { artistTopTracksMock } from './mocks/artists/artist-top-tracks.mock';
import {
checkMatchingArtistAttributes,
checkMatchingPagingObjectAttributes,
Expand Down Expand Up @@ -59,7 +56,7 @@ describe('Artist requests', () => {
'1WgXqy2Dd70QQOU7Ay074N',
]);

for (let i = 0; i < severalArtistsResponse.length; i++) {
for (let i = 0; i < severalArtistsResponse.length; i += 1) {
const artistResponse = severalArtistsResponse[i];
const artistMock = severalArtistsMock.artists[i];
checkMatchingArtistAttributes(artistResponse, artistMock);
Expand Down Expand Up @@ -99,10 +96,9 @@ describe('Artist requests', () => {
'1WgXqy2Dd70QQOU7Ay074N'
);

for (let i = 0; i < artistRelatedArtistsResponse.length; i++) {
for (let i = 0; i < artistRelatedArtistsResponse.length; i += 1) {
const artistResponse: Artist = artistRelatedArtistsResponse[i];
const artistMock: ArtistMock =
artistRelatedArtistsMock.artists[i];
const artistMock: any = artistRelatedArtistsMock.artists[i];
checkMatchingArtistAttributes(artistResponse, artistMock);
}
});
Expand All @@ -122,9 +118,9 @@ describe('Artist requests', () => {
'BR'
);

for (let i = 0; i < artistTopTracksResponse.length; i++) {
for (let i = 0; i < artistTopTracksResponse.length; i += 1) {
const topTrackResponse: Track = artistTopTracksResponse[i];
const topTrackMock: TrackMock = artistTopTracksMock.tracks[i];
const topTrackMock = artistTopTracksMock.tracks[i];
checkMatchingTrackAttributes(topTrackResponse, topTrackMock);
}
});
Expand Down
4 changes: 2 additions & 2 deletions test/browse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('Browse requests', () => {

it('response should match all tracks attributes', async () => {
const recommendationsResponse = await getRecommendations(params);
for (let i = 0; i < recommendationsResponse.tracks.length; i++) {
for (let i = 0; i < recommendationsResponse.tracks.length; i += 1) {
const trackResponse = recommendationsResponse.tracks[i];
const trackMock = recommendationsMock.tracks[i];
checkMatchingTrackSimplifiedAttributes(
Expand All @@ -153,7 +153,7 @@ describe('Browse requests', () => {

it('response should match all seeds attributes', async () => {
const recommendationsResponse = await getRecommendations(params);
for (let i = 0; i < recommendationsResponse.seeds.length; i++) {
for (let i = 0; i < recommendationsResponse.seeds.length; i += 1) {
const seedResponse = recommendationsResponse.seeds[i];
const seedMock = recommendationsMock.seeds[i];
checkMatchingRecommendationSeedAttributes(
Expand Down

0 comments on commit 85a7624

Please sign in to comment.