@sprucelabs/spruce-invite-utils 4.0.0 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,16 @@
1
+ import { SpruceSchemas } from '@sprucelabs/mercury-types';
1
2
  import { LoginAndConfirmJoinOptions, PromptForLoginAndConfirmOptions } from '../../loggingInAndConfirmingJoin/LoginAndConfirmJoinController';
2
3
  export default class LoginAndConfirmTestFixture {
3
4
  private static hitCount;
4
5
  private static wasBeforeEachCalled;
5
6
  static lastPromptOptions?: PromptForLoginAndConfirmOptions;
6
7
  static lastFactoryOptions?: LoginAndConfirmJoinOptions;
8
+ private static loginAndJoinResponse;
7
9
  static beforeEach(): void;
8
10
  static getHitCount(): number;
9
11
  private static assertBeforeEachWasCalled;
10
- static setResponse(r: boolean): void;
12
+ static setResponse(person: Person | null): void;
11
13
  private static setClass;
12
14
  }
15
+ declare type Person = SpruceSchemas.Spruce.v2020_07_22.Person;
16
+ export {};
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const test_1 = require("@sprucelabs/test");
4
+ const test_utils_1 = require("@sprucelabs/test-utils");
4
5
  const LoginAndConfirmJoinController_1 = require("../../loggingInAndConfirmingJoin/LoginAndConfirmJoinController");
5
6
  class LoginAndConfirmTestFixture {
6
7
  static beforeEach() {
7
8
  this.setClass(CountingLoginAndConfirmController);
8
9
  this.hitCount = 0;
9
10
  this.wasBeforeEachCalled = true;
11
+ this.loginAndJoinResponse = undefined;
10
12
  }
11
13
  static getHitCount() {
12
14
  this.assertBeforeEachWasCalled();
@@ -15,12 +17,13 @@ class LoginAndConfirmTestFixture {
15
17
  static assertBeforeEachWasCalled() {
16
18
  test_1.assert.isTrue(this.wasBeforeEachCalled, `Make sure you call 'LoginAndConfirmTestFixture.beforeEach()' in your test!`);
17
19
  }
18
- static setResponse(r) {
20
+ static setResponse(person) {
19
21
  this.assertBeforeEachWasCalled();
20
- const Class = r
21
- ? PassingLoginAndConfirmController
22
+ const Class = person
23
+ ? CountingLoginAndConfirmController
22
24
  : FailingLoginAndConfirmController;
23
25
  this.setClass(Class);
26
+ this.loginAndJoinResponse = person;
24
27
  }
25
28
  static setClass(Class) {
26
29
  LoginAndConfirmJoinController_1.LoginAndConfirmJoinControllerFactory.setClass(Class);
@@ -29,19 +32,24 @@ class LoginAndConfirmTestFixture {
29
32
  exports.default = LoginAndConfirmTestFixture;
30
33
  LoginAndConfirmTestFixture.hitCount = 0;
31
34
  LoginAndConfirmTestFixture.wasBeforeEachCalled = false;
35
+ LoginAndConfirmTestFixture.loginAndJoinResponse = undefined;
32
36
  class CountingLoginAndConfirmController {
33
37
  constructor(options) {
34
38
  LoginAndConfirmTestFixture.lastFactoryOptions = options;
39
+ this.auth = options.authenticator;
35
40
  }
36
41
  async promptForLoginAndConfirmJoin(options) {
37
42
  //@ts-ignore
38
43
  LoginAndConfirmTestFixture.hitCount++;
39
44
  LoginAndConfirmTestFixture.lastPromptOptions = options;
40
- return true;
41
- }
42
- }
43
- class PassingLoginAndConfirmController {
44
- async promptForLoginAndConfirmJoin() {
45
+ //@ts-ignore
46
+ const response = LoginAndConfirmTestFixture.loginAndJoinResponse;
47
+ if (response) {
48
+ this.auth.setSessionToken((0, test_utils_1.generateId)(), response);
49
+ }
50
+ else if (response === null) {
51
+ this.auth.clearSession();
52
+ }
45
53
  return true;
46
54
  }
47
55
  }
@@ -1,12 +1,16 @@
1
+ import { SpruceSchemas } from '@sprucelabs/mercury-types';
1
2
  import { LoginAndConfirmJoinOptions, PromptForLoginAndConfirmOptions } from '../../loggingInAndConfirmingJoin/LoginAndConfirmJoinController';
2
3
  export default class LoginAndConfirmTestFixture {
3
4
  private static hitCount;
4
5
  private static wasBeforeEachCalled;
5
6
  static lastPromptOptions?: PromptForLoginAndConfirmOptions;
6
7
  static lastFactoryOptions?: LoginAndConfirmJoinOptions;
8
+ private static loginAndJoinResponse;
7
9
  static beforeEach(): void;
8
10
  static getHitCount(): number;
9
11
  private static assertBeforeEachWasCalled;
10
- static setResponse(r: boolean): void;
12
+ static setResponse(person: Person | null): void;
11
13
  private static setClass;
12
14
  }
15
+ declare type Person = SpruceSchemas.Spruce.v2020_07_22.Person;
16
+ export {};
@@ -8,12 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { assert } from '@sprucelabs/test';
11
+ import { generateId } from '@sprucelabs/test-utils';
11
12
  import { LoginAndConfirmJoinControllerFactory, } from '../../loggingInAndConfirmingJoin/LoginAndConfirmJoinController.js';
12
13
  export default class LoginAndConfirmTestFixture {
13
14
  static beforeEach() {
14
15
  this.setClass(CountingLoginAndConfirmController);
15
16
  this.hitCount = 0;
16
17
  this.wasBeforeEachCalled = true;
18
+ this.loginAndJoinResponse = undefined;
17
19
  }
18
20
  static getHitCount() {
19
21
  this.assertBeforeEachWasCalled();
@@ -22,12 +24,13 @@ export default class LoginAndConfirmTestFixture {
22
24
  static assertBeforeEachWasCalled() {
23
25
  assert.isTrue(this.wasBeforeEachCalled, `Make sure you call 'LoginAndConfirmTestFixture.beforeEach()' in your test!`);
24
26
  }
25
- static setResponse(r) {
27
+ static setResponse(person) {
26
28
  this.assertBeforeEachWasCalled();
27
- const Class = r
28
- ? PassingLoginAndConfirmController
29
+ const Class = person
30
+ ? CountingLoginAndConfirmController
29
31
  : FailingLoginAndConfirmController;
30
32
  this.setClass(Class);
33
+ this.loginAndJoinResponse = person;
31
34
  }
32
35
  static setClass(Class) {
33
36
  LoginAndConfirmJoinControllerFactory.setClass(Class);
@@ -35,22 +38,25 @@ export default class LoginAndConfirmTestFixture {
35
38
  }
36
39
  LoginAndConfirmTestFixture.hitCount = 0;
37
40
  LoginAndConfirmTestFixture.wasBeforeEachCalled = false;
41
+ LoginAndConfirmTestFixture.loginAndJoinResponse = undefined;
38
42
  class CountingLoginAndConfirmController {
39
43
  constructor(options) {
40
44
  LoginAndConfirmTestFixture.lastFactoryOptions = options;
45
+ this.auth = options.authenticator;
41
46
  }
42
47
  promptForLoginAndConfirmJoin(options) {
43
48
  return __awaiter(this, void 0, void 0, function* () {
44
49
  //@ts-ignore
45
50
  LoginAndConfirmTestFixture.hitCount++;
46
51
  LoginAndConfirmTestFixture.lastPromptOptions = options;
47
- return true;
48
- });
49
- }
50
- }
51
- class PassingLoginAndConfirmController {
52
- promptForLoginAndConfirmJoin() {
53
- return __awaiter(this, void 0, void 0, function* () {
52
+ //@ts-ignore
53
+ const response = LoginAndConfirmTestFixture.loginAndJoinResponse;
54
+ if (response) {
55
+ this.auth.setSessionToken(generateId(), response);
56
+ }
57
+ else if (response === null) {
58
+ this.auth.clearSession();
59
+ }
54
60
  return true;
55
61
  });
56
62
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sprucelabs/spruce-invite-utils",
3
3
  "description": "Invite Utilities",
4
- "version": "4.0.0",
4
+ "version": "5.0.2",
5
5
  "skill": {
6
6
  "namespace": "invite"
7
7
  },