@sprucelabs/spruce-invite-utils 4.0.0 → 5.0.0

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
+ static loginAndJoinResponse: Person | null | undefined;
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,6 +1,7 @@
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() {
@@ -15,12 +16,13 @@ class LoginAndConfirmTestFixture {
15
16
  static assertBeforeEachWasCalled() {
16
17
  test_1.assert.isTrue(this.wasBeforeEachCalled, `Make sure you call 'LoginAndConfirmTestFixture.beforeEach()' in your test!`);
17
18
  }
18
- static setResponse(r) {
19
+ static setResponse(person) {
19
20
  this.assertBeforeEachWasCalled();
20
- const Class = r
21
+ const Class = person
21
22
  ? PassingLoginAndConfirmController
22
23
  : FailingLoginAndConfirmController;
23
24
  this.setClass(Class);
25
+ this.loginAndJoinResponse = person;
24
26
  }
25
27
  static setClass(Class) {
26
28
  LoginAndConfirmJoinController_1.LoginAndConfirmJoinControllerFactory.setClass(Class);
@@ -29,19 +31,38 @@ class LoginAndConfirmTestFixture {
29
31
  exports.default = LoginAndConfirmTestFixture;
30
32
  LoginAndConfirmTestFixture.hitCount = 0;
31
33
  LoginAndConfirmTestFixture.wasBeforeEachCalled = false;
34
+ LoginAndConfirmTestFixture.loginAndJoinResponse = undefined;
32
35
  class CountingLoginAndConfirmController {
33
36
  constructor(options) {
34
37
  LoginAndConfirmTestFixture.lastFactoryOptions = options;
38
+ this.auth = options.authenticator;
35
39
  }
36
40
  async promptForLoginAndConfirmJoin(options) {
37
41
  //@ts-ignore
38
42
  LoginAndConfirmTestFixture.hitCount++;
39
43
  LoginAndConfirmTestFixture.lastPromptOptions = options;
44
+ const response = LoginAndConfirmTestFixture.loginAndJoinResponse;
45
+ if (response) {
46
+ this.auth.setSessionToken((0, test_utils_1.generateId)(), response);
47
+ }
48
+ else if (response === null) {
49
+ this.auth.clearSession();
50
+ }
40
51
  return true;
41
52
  }
42
53
  }
43
54
  class PassingLoginAndConfirmController {
55
+ constructor(options) {
56
+ this.auth = options.authenticator;
57
+ }
44
58
  async promptForLoginAndConfirmJoin() {
59
+ const response = LoginAndConfirmTestFixture.loginAndJoinResponse;
60
+ if (response) {
61
+ this.auth.setSessionToken((0, test_utils_1.generateId)(), response);
62
+ }
63
+ else if (response === null) {
64
+ this.auth.clearSession();
65
+ }
45
66
  return true;
46
67
  }
47
68
  }
@@ -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
+ static loginAndJoinResponse: Person | null | undefined;
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,6 +8,7 @@ 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() {
@@ -22,12 +23,13 @@ export default class LoginAndConfirmTestFixture {
22
23
  static assertBeforeEachWasCalled() {
23
24
  assert.isTrue(this.wasBeforeEachCalled, `Make sure you call 'LoginAndConfirmTestFixture.beforeEach()' in your test!`);
24
25
  }
25
- static setResponse(r) {
26
+ static setResponse(person) {
26
27
  this.assertBeforeEachWasCalled();
27
- const Class = r
28
+ const Class = person
28
29
  ? PassingLoginAndConfirmController
29
30
  : FailingLoginAndConfirmController;
30
31
  this.setClass(Class);
32
+ this.loginAndJoinResponse = person;
31
33
  }
32
34
  static setClass(Class) {
33
35
  LoginAndConfirmJoinControllerFactory.setClass(Class);
@@ -35,22 +37,41 @@ export default class LoginAndConfirmTestFixture {
35
37
  }
36
38
  LoginAndConfirmTestFixture.hitCount = 0;
37
39
  LoginAndConfirmTestFixture.wasBeforeEachCalled = false;
40
+ LoginAndConfirmTestFixture.loginAndJoinResponse = undefined;
38
41
  class CountingLoginAndConfirmController {
39
42
  constructor(options) {
40
43
  LoginAndConfirmTestFixture.lastFactoryOptions = options;
44
+ this.auth = options.authenticator;
41
45
  }
42
46
  promptForLoginAndConfirmJoin(options) {
43
47
  return __awaiter(this, void 0, void 0, function* () {
44
48
  //@ts-ignore
45
49
  LoginAndConfirmTestFixture.hitCount++;
46
50
  LoginAndConfirmTestFixture.lastPromptOptions = options;
51
+ const response = LoginAndConfirmTestFixture.loginAndJoinResponse;
52
+ if (response) {
53
+ this.auth.setSessionToken(generateId(), response);
54
+ }
55
+ else if (response === null) {
56
+ this.auth.clearSession();
57
+ }
47
58
  return true;
48
59
  });
49
60
  }
50
61
  }
51
62
  class PassingLoginAndConfirmController {
63
+ constructor(options) {
64
+ this.auth = options.authenticator;
65
+ }
52
66
  promptForLoginAndConfirmJoin() {
53
67
  return __awaiter(this, void 0, void 0, function* () {
68
+ const response = LoginAndConfirmTestFixture.loginAndJoinResponse;
69
+ if (response) {
70
+ this.auth.setSessionToken(generateId(), response);
71
+ }
72
+ else if (response === null) {
73
+ this.auth.clearSession();
74
+ }
54
75
  return true;
55
76
  });
56
77
  }
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.0",
5
5
  "skill": {
6
6
  "namespace": "invite"
7
7
  },