Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

[WIP] Ensure scopes defined in scopes.equals() #160

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/auth/scopes/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//import {MissingRequiredArgument} from '../../error';

class AuthScopes {
public static SCOPE_DELIMITER = ',';

Expand Down Expand Up @@ -38,6 +40,10 @@ class AuthScopes {
public equals(otherScopes: string | string[] | AuthScopes) {
let other: AuthScopes;

// if (!otherScopes) {
// throw new MissingRequiredArgument('Missing scopes');
// }

if (otherScopes instanceof AuthScopes) {
other = otherScopes;
} else {
Expand Down
8 changes: 8 additions & 0 deletions src/auth/scopes/test/scopes.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import '../../../test/test_helper';
import * as ShopifyErrors from '../../../error';

import {AuthScopes} from '../index';

Expand Down Expand Up @@ -65,6 +66,13 @@ describe('AuthScopes.equals', () => {
expect(scopes2.equals(scopes1)).toBeFalsy();
});

it('throws an error if no scopes', () => {
const scopes1 = new AuthScopes('write_customers,read_products');
const scopes2: string = '';

expect(scopes1.equals(scopes2)).toThrow(ShopifyErrors.MissingRequiredArgument);
})

it('allows comparing against strings', () => {
const scopes1 = new AuthScopes('write_customers,read_products,write_products');

Expand Down