Skip to content

Commit

Permalink
fix(constructor): remove hasBeenInstantiated flag checks (#49)
Browse files Browse the repository at this point in the history
* chore: Remove hasBeenInstantiated unit tests
* chore: adds contributing section to README.md
  • Loading branch information
AlbertLapTu authored and gurpreetatwal committed Oct 2, 2019
1 parent 03f48eb commit ad9ca2d
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 28 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ npm install @smartcar/auth
### Smartcar CDN

```html
<script src="https://javascript-sdk.smartcar.com/2.4.0/sdk.js"></script>
<script src="https://javascript-sdk.smartcar.com/2.4.1/sdk.js"></script>
```

Before v2.2.0, the SDK was versioned as follows:
Expand Down Expand Up @@ -192,4 +192,4 @@ https://application-backend.com/page?error=access_denied&error_description=User+
[tag-image]: https://img.shields.io/github/tag/smartcar/javascript-sdk.svg

<!-- Please do not modify or remove this, it is used by the build process -->
[version]: 2.4.0
[version]: 2.4.1
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@smartcar/auth",
"version": "2.4.0",
"version": "2.4.1",
"description": "javascript auth sdk for the smartcar",
"main": "dist/npm/sdk.js",
"license": "MIT",
Expand Down
10 changes: 0 additions & 10 deletions src/sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,6 @@ class Smartcar {
* @param {Object} options - the SDK configuration object
*/
static _validateConstructorOptions(options) {
// allow only one instance of Smartcar
if (Smartcar._hasBeenInstantiated) {
throw new Error(
'Smartcar has already been instantiated in the window. Only one' +
' instance of Smartcar can be defined.',
);
} else {
Smartcar._hasBeenInstantiated = true;
}

if (!options.clientId) {
throw new TypeError('A client ID option must be provided');
}
Expand Down
14 changes: 0 additions & 14 deletions test/unit/sdk.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ const isValidWindowOptions = (str) =>
describe('sdk', () => {
const CDN_ORIGIN = 'https://javascript-sdk.smartcar.com';

beforeEach(() => {
Smartcar._hasBeenInstantiated = false;
});

describe('constructor', () => {
test('throws error if constructor called without redirectUri', () => {
expect(() => new Smartcar({clientId: 'uuid'})).toThrow(
Expand All @@ -25,16 +21,6 @@ describe('sdk', () => {
);
});

test('throws error if smartcar already instantiated', () => {
// initial instantiation
// eslint-disable-next-line no-new
new Smartcar({redirectUri: 'http://example.com', clientId: 'my-id'});
expect(() => new Smartcar({redirectUri: 'http://example.com', clientId: 'my-id'})).toThrow(
'Smartcar has already been instantiated in the window. Only one' +
' instance of Smartcar can be defined.',
);
});

test('throws error if using Smartcar hosting without onComplete', () => {
expect(
() =>
Expand Down

0 comments on commit ad9ca2d

Please sign in to comment.