seatsio 66.0.0 → 67.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.
- package/package.json +1 -1
- package/src/AsyncIterator.js +3 -3
- package/src/Charts/Chart.js +2 -2
- package/src/Charts/Charts.js +1 -1
- package/src/Events/Event.js +4 -0
- package/src/Events/EventDeserializer.js +13 -0
- package/src/Events/Events.js +5 -5
- package/src/Invitations/Invitations.js +1 -1
- package/src/Seasons/Season.js +7 -5
- package/src/Seasons/Seasons.js +8 -80
- package/src/SeatsioClient.js +2 -2
- package/src/Subaccounts/Subaccounts.js +1 -1
- package/src/Users/Users.js +1 -1
- package/src/Workspaces/Workspaces.js +1 -1
- package/tests/events/listAllEvents.test.js +16 -1
- package/tests/events/retrieveEvent.test.js +23 -0
- package/tests/seasons/createSeason.test.js +10 -14
- package/tests/seasons/retrieveSeason.test.js +6 -10
- package/tests/seasons/deletePartialSeason.test.js +0 -18
- package/tests/seasons/deleteSeason.test.js +0 -17
- package/tests/seasons/listAllSeasons.test.js +0 -16
- package/tests/seasons/retrievePartialSeason.test.js +0 -25
package/package.json
CHANGED
package/src/AsyncIterator.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const Page = require('./Page.js')
|
|
2
2
|
const StatusChange = require('./Events/StatusChange.js')
|
|
3
3
|
const Chart = require('./Charts/Chart.js')
|
|
4
|
-
const Event = require('./Events/Event.js')
|
|
5
4
|
const User = require('./Users/User.js')
|
|
6
5
|
const Subaccount = require('./Subaccounts/Subaccount.js')
|
|
7
6
|
const Workspace = require('./Workspaces/Workspace.js')
|
|
8
7
|
const Season = require('./Seasons/Season')
|
|
8
|
+
const EventDeserializer = require('./Events/EventDeserializer')
|
|
9
9
|
|
|
10
10
|
class AsyncIterator {
|
|
11
11
|
/**
|
|
12
12
|
* @param {string} url
|
|
13
|
-
* @param {
|
|
13
|
+
* @param {Axios} client
|
|
14
14
|
* @param {string} objType
|
|
15
15
|
* @param {object} params
|
|
16
16
|
*/
|
|
@@ -39,7 +39,7 @@ class AsyncIterator {
|
|
|
39
39
|
events (data) {
|
|
40
40
|
const events = []
|
|
41
41
|
data.items.forEach(eventData => {
|
|
42
|
-
const event = new
|
|
42
|
+
const event = new EventDeserializer().fromJson(eventData)
|
|
43
43
|
this.items.push(event)
|
|
44
44
|
events.push(event)
|
|
45
45
|
})
|
package/src/Charts/Chart.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const Event = require('../Events/Event.js')
|
|
2
1
|
const ChartValidation = require('./ChartValidation')
|
|
3
2
|
const SocialDistancingRuleset = require('./SocialDistancingRuleset')
|
|
3
|
+
const EventDeserializer = require('../Events/EventDeserializer')
|
|
4
4
|
|
|
5
5
|
class Chart {
|
|
6
6
|
/**
|
|
@@ -14,7 +14,7 @@ class Chart {
|
|
|
14
14
|
this.tags = chart.tags
|
|
15
15
|
this.publishedVersionThumbnailUrl = chart.publishedVersionThumbnailUrl
|
|
16
16
|
this.draftVersionThumbnailUrl = chart.draftVersionThumbnailUrl || null
|
|
17
|
-
this.events = chart.events ? chart.events.map(event => new
|
|
17
|
+
this.events = chart.events ? chart.events.map(event => new EventDeserializer().fromJson(event)) : []
|
|
18
18
|
this.archived = chart.archived
|
|
19
19
|
if (chart.validation) this.validation = new ChartValidation(chart.validation)
|
|
20
20
|
this.socialDistancingRulesets = Chart.socialDistancingRulesetsFromJson(chart.socialDistancingRulesets)
|
package/src/Charts/Charts.js
CHANGED
package/src/Events/Event.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const Season = require('../Seasons/Season')
|
|
2
|
+
const Event = require('./Event.js')
|
|
3
|
+
|
|
4
|
+
class EventDeserializer {
|
|
5
|
+
fromJson (event) {
|
|
6
|
+
if (event.isSeason) {
|
|
7
|
+
return new Season(event)
|
|
8
|
+
}
|
|
9
|
+
return new Event(event)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = EventDeserializer
|
package/src/Events/Events.js
CHANGED
|
@@ -4,11 +4,11 @@ const EventObjectInfo = require('./EventObjectInfo.js')
|
|
|
4
4
|
const StatusChange = require('./StatusChange.js')
|
|
5
5
|
const BestAvailableObjects = require('./BestAvailableObjects.js')
|
|
6
6
|
const ChangeObjectStatusResult = require('./ChangeObjectStatusResult.js')
|
|
7
|
-
const
|
|
7
|
+
const EventDeserializer = require('./EventDeserializer')
|
|
8
8
|
|
|
9
9
|
class Events {
|
|
10
10
|
/**
|
|
11
|
-
* @param {
|
|
11
|
+
* @param {Axios} client
|
|
12
12
|
*/
|
|
13
13
|
constructor (client) {
|
|
14
14
|
this.client = client
|
|
@@ -40,7 +40,7 @@ class Events {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
return this.client.post('/events', requestParameters)
|
|
43
|
-
.then((res) => new
|
|
43
|
+
.then((res) => new EventDeserializer().fromJson(res.data))
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -49,7 +49,7 @@ class Events {
|
|
|
49
49
|
*/
|
|
50
50
|
retrieve (eventKey) {
|
|
51
51
|
return this.client.get(`/events/${encodeURIComponent(eventKey)}`)
|
|
52
|
-
.then((res) => new
|
|
52
|
+
.then((res) => new EventDeserializer().fromJson(res.data))
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
updateChannels (eventKey, channels) {
|
|
@@ -137,7 +137,7 @@ class Events {
|
|
|
137
137
|
*/
|
|
138
138
|
iterator () {
|
|
139
139
|
return new Lister('/events', this.client, 'events', (data) => {
|
|
140
|
-
const events = data.items.map(eventData => new
|
|
140
|
+
const events = data.items.map(eventData => new EventDeserializer().fromJson(eventData))
|
|
141
141
|
return new Page(events, data.next_page_starts_after, data.previous_page_ends_before)
|
|
142
142
|
})
|
|
143
143
|
}
|
package/src/Seasons/Season.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
const Event = require('../Events/Event.js')
|
|
2
2
|
|
|
3
|
-
class Season {
|
|
3
|
+
class Season extends Event {
|
|
4
4
|
/**
|
|
5
5
|
* @param {object} season
|
|
6
6
|
*/
|
|
7
7
|
constructor (season) {
|
|
8
|
-
|
|
9
|
-
this.key = season.key
|
|
10
|
-
this.seasonEvent = new Event(season.seasonEvent)
|
|
8
|
+
super(season)
|
|
11
9
|
this.partialSeasonKeys = season.partialSeasonKeys
|
|
12
|
-
this.events = season.events.map(e => new Event(e))
|
|
10
|
+
this.events = season.events ? season.events.map(e => new Event(e)) : undefined
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
isSeason () {
|
|
14
|
+
return true
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
|
package/src/Seasons/Seasons.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const Page = require('../Page.js')
|
|
2
|
-
const Lister = require('../Lister.js')
|
|
3
1
|
const Season = require('./Season')
|
|
4
2
|
|
|
5
3
|
class Seasons {
|
|
6
4
|
/**
|
|
7
|
-
* @param {
|
|
5
|
+
* @param {Axios} client
|
|
6
|
+
* @param {SeatsioClient} seatsioClient
|
|
8
7
|
*/
|
|
9
|
-
constructor (client) {
|
|
8
|
+
constructor (client, seatsioClient) {
|
|
10
9
|
this.client = client
|
|
10
|
+
this.seatsioClient = seatsioClient
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -66,25 +66,6 @@ class Seasons {
|
|
|
66
66
|
.then((res) => new Season(res.data))
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
/**
|
|
70
|
-
* @param {string} key
|
|
71
|
-
* @returns {Promise<Season>}
|
|
72
|
-
*/
|
|
73
|
-
retrieve (key) {
|
|
74
|
-
return this.client.get(`/seasons/${encodeURIComponent(key)}`)
|
|
75
|
-
.then((res) => new Season(res.data))
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* @param {string} topLevelSeasonKey
|
|
80
|
-
* @param {?string} partialSeasonKey
|
|
81
|
-
* @returns {Promise<Season>}
|
|
82
|
-
*/
|
|
83
|
-
retrievePartialSeason (topLevelSeasonKey, partialSeasonKey) {
|
|
84
|
-
return this.client.get(`/seasons/${encodeURIComponent(topLevelSeasonKey)}/partial-seasons/${encodeURIComponent(partialSeasonKey)}`)
|
|
85
|
-
.then((res) => new Season(res.data))
|
|
86
|
-
}
|
|
87
|
-
|
|
88
69
|
/**
|
|
89
70
|
* @param {string} key
|
|
90
71
|
* @param {?number} numberOfEvents
|
|
@@ -118,23 +99,6 @@ class Seasons {
|
|
|
118
99
|
.then((res) => new Season(res.data))
|
|
119
100
|
}
|
|
120
101
|
|
|
121
|
-
/**
|
|
122
|
-
* @param {string} key
|
|
123
|
-
* @returns {Promise}
|
|
124
|
-
*/
|
|
125
|
-
delete (key) {
|
|
126
|
-
return this.client.delete(`/seasons/${encodeURIComponent(key)}`)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* @param {string} topLevelSeasonKey
|
|
131
|
-
* @param {string} partialSeasonKey
|
|
132
|
-
* @returns {Promise<void>}
|
|
133
|
-
*/
|
|
134
|
-
deletePartialSeason (topLevelSeasonKey, partialSeasonKey) {
|
|
135
|
-
return this.client.delete(`/seasons/${encodeURIComponent(topLevelSeasonKey)}/partial-seasons/${encodeURIComponent(partialSeasonKey)}`)
|
|
136
|
-
}
|
|
137
|
-
|
|
138
102
|
/**
|
|
139
103
|
* @param {string} topLevelSeasonKey
|
|
140
104
|
* @param {string} partialSeasonKey
|
|
@@ -147,47 +111,11 @@ class Seasons {
|
|
|
147
111
|
}
|
|
148
112
|
|
|
149
113
|
/**
|
|
150
|
-
* @param {
|
|
151
|
-
* @returns {
|
|
152
|
-
*/
|
|
153
|
-
listAll (requestParameters = {}) {
|
|
154
|
-
return this.iterator().all(requestParameters)
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* @param {?number} pageSize
|
|
159
|
-
* @returns {Page<Season>}
|
|
160
|
-
*/
|
|
161
|
-
listFirstPage (pageSize = null) {
|
|
162
|
-
return this.iterator().firstPage(null, pageSize)
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* @param {?string} afterId
|
|
167
|
-
* @param {?number} pageSize
|
|
168
|
-
* @returns {Page<Season>}
|
|
169
|
-
*/
|
|
170
|
-
listPageAfter (afterId, pageSize = null) {
|
|
171
|
-
return this.iterator().pageAfter(afterId, null, pageSize)
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* @param {?string} beforeId
|
|
176
|
-
* @param {?number} pageSize
|
|
177
|
-
* @returns {Page<Season>}
|
|
178
|
-
*/
|
|
179
|
-
listPageBefore (beforeId, pageSize = null) {
|
|
180
|
-
return this.iterator().pageBefore(beforeId, null, pageSize)
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* @returns {Lister}
|
|
114
|
+
* @param {string} key
|
|
115
|
+
* @returns {Promise<Season>}
|
|
185
116
|
*/
|
|
186
|
-
|
|
187
|
-
return
|
|
188
|
-
const seasons = data.items.map(seasonData => new Season(seasonData))
|
|
189
|
-
return new Page(seasons, data.next_page_starts_after, data.previous_page_ends_before)
|
|
190
|
-
})
|
|
117
|
+
retrieve (key) {
|
|
118
|
+
return this.seatsioClient.events.retrieve(key)
|
|
191
119
|
}
|
|
192
120
|
}
|
|
193
121
|
|
package/src/SeatsioClient.js
CHANGED
|
@@ -23,7 +23,7 @@ class SeatsioClient {
|
|
|
23
23
|
this.errInterceptor = this.client.interceptors.response.use(response => response, errorResponseHandler)
|
|
24
24
|
|
|
25
25
|
this.charts = new Charts(this.client)
|
|
26
|
-
this.events = new Events(this.client)
|
|
26
|
+
this.events = new Events(this.client, this)
|
|
27
27
|
this.subaccounts = new Subaccounts(this.client)
|
|
28
28
|
this.workspaces = new Workspaces(this.client)
|
|
29
29
|
this.users = new Users(this.client)
|
|
@@ -33,7 +33,7 @@ class SeatsioClient {
|
|
|
33
33
|
this.chartReports = new ChartReports(this.client)
|
|
34
34
|
this.eventReports = new EventReports(this.client)
|
|
35
35
|
this.usageReports = new UsageReports(this.client)
|
|
36
|
-
this.seasons = new Seasons(this.client)
|
|
36
|
+
this.seasons = new Seasons(this.client, this)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
_axiosConfig (baseUrl, secretKey, workspaceKey, extraHeaders) {
|
package/src/Users/Users.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const testUtils = require('../testUtils.js')
|
|
2
2
|
|
|
3
3
|
test('listAll events when there are more than 10 events)', async () => {
|
|
4
|
-
const { client
|
|
4
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
5
5
|
const chart = await client.charts.create()
|
|
6
6
|
|
|
7
7
|
const events = await testUtils.createArray(15, () => client.events.create(chart.key))
|
|
@@ -13,3 +13,18 @@ test('listAll events when there are more than 10 events)', async () => {
|
|
|
13
13
|
|
|
14
14
|
expect(retrievedEventKeys.sort()).toEqual(events.map(e => e.key).sort())
|
|
15
15
|
})
|
|
16
|
+
|
|
17
|
+
test('list seasons', async () => {
|
|
18
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
19
|
+
const chart = await client.charts.create()
|
|
20
|
+
await client.seasons.create(chart.key)
|
|
21
|
+
await client.seasons.create(chart.key)
|
|
22
|
+
await client.seasons.create(chart.key)
|
|
23
|
+
|
|
24
|
+
const areSeasons = []
|
|
25
|
+
for await (const season of client.events.listAll()) {
|
|
26
|
+
areSeasons.push(season.isSeason())
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
expect(areSeasons).toEqual([true, true, true])
|
|
30
|
+
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const testUtils = require('../testUtils.js')
|
|
2
2
|
const TableBookingConfig = require('../../src/Events/TableBookingConfig')
|
|
3
|
+
const SeasonParams = require("../../src/Seasons/SeasonParams");
|
|
3
4
|
|
|
4
5
|
test('should retrieve event', async () => {
|
|
5
6
|
const { client, user } = await testUtils.createTestUserAndClient()
|
|
@@ -20,3 +21,25 @@ test('should retrieve event', async () => {
|
|
|
20
21
|
expect(retrievedEvent.forSaleConfig).toBeFalsy()
|
|
21
22
|
expect(retrievedEvent.updatedOn).toBeNull()
|
|
22
23
|
})
|
|
24
|
+
|
|
25
|
+
test('retrieve season', async () => {
|
|
26
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
27
|
+
const chartKey = testUtils.getChartKey()
|
|
28
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
29
|
+
const season = await client.seasons.create(chartKey, new SeasonParams().eventKeys(['event1', 'event2']))
|
|
30
|
+
const partialSeason1 = await client.seasons.createPartialSeason(season.key)
|
|
31
|
+
const partialSeason2 = await client.seasons.createPartialSeason(season.key)
|
|
32
|
+
|
|
33
|
+
const retrievedSeason = await client.events.retrieve(season.key)
|
|
34
|
+
|
|
35
|
+
expect(retrievedSeason.key).toBeTruthy()
|
|
36
|
+
expect(retrievedSeason.id).toBeTruthy()
|
|
37
|
+
expect(retrievedSeason.partialSeasonKeys).toEqual([partialSeason1.key, partialSeason2.key])
|
|
38
|
+
expect(retrievedSeason.events.map(e => e.key)).toEqual(['event1', 'event2'])
|
|
39
|
+
expect(retrievedSeason.chartKey).toBe(chartKey)
|
|
40
|
+
expect(retrievedSeason.tableBookingConfig).toEqual(TableBookingConfig.inherit())
|
|
41
|
+
expect(retrievedSeason.supportsBestAvailable).toBe(true)
|
|
42
|
+
expect(retrievedSeason.createdOn).toBeInstanceOf(Date)
|
|
43
|
+
expect(retrievedSeason.forSaleConfig).toBeFalsy()
|
|
44
|
+
expect(retrievedSeason.updatedOn).toBeFalsy()
|
|
45
|
+
})
|
|
@@ -10,20 +10,16 @@ test('chart key is required', async () => {
|
|
|
10
10
|
|
|
11
11
|
const season = await client.seasons.create(chartKey)
|
|
12
12
|
|
|
13
|
-
expect(season.key).toBeTruthy()
|
|
14
|
-
expect(season.id).toBeTruthy()
|
|
15
13
|
expect(season.partialSeasonKeys.length).toBe(0)
|
|
16
14
|
expect(season.events.length).toBe(0)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
expect(
|
|
20
|
-
expect(
|
|
21
|
-
expect(
|
|
22
|
-
expect(
|
|
23
|
-
expect(
|
|
24
|
-
expect(
|
|
25
|
-
expect(seasonEvent.forSaleConfig).toBeFalsy()
|
|
26
|
-
expect(seasonEvent.updatedOn).toBeFalsy()
|
|
15
|
+
expect(season.id).toBeTruthy()
|
|
16
|
+
expect(season.key).toBe(season.key)
|
|
17
|
+
expect(season.chartKey).toBe(chartKey)
|
|
18
|
+
expect(season.tableBookingConfig).toEqual(TableBookingConfig.inherit())
|
|
19
|
+
expect(season.supportsBestAvailable).toBe(true)
|
|
20
|
+
expect(season.createdOn).toBeInstanceOf(Date)
|
|
21
|
+
expect(season.forSaleConfig).toBeFalsy()
|
|
22
|
+
expect(season.updatedOn).toBeFalsy()
|
|
27
23
|
})
|
|
28
24
|
|
|
29
25
|
test('key can be passed in', async () => {
|
|
@@ -61,7 +57,7 @@ test('table booking config can be passed in', async () => {
|
|
|
61
57
|
|
|
62
58
|
const season = await client.seasons.create(chartKey, new SeasonParams().tableBookingConfig(tableBookingConfig))
|
|
63
59
|
|
|
64
|
-
expect(season.
|
|
60
|
+
expect(season.tableBookingConfig).toEqual(tableBookingConfig)
|
|
65
61
|
})
|
|
66
62
|
|
|
67
63
|
test('social distancing ruleset key can be passed in', async () => {
|
|
@@ -72,5 +68,5 @@ test('social distancing ruleset key can be passed in', async () => {
|
|
|
72
68
|
|
|
73
69
|
const season = await client.seasons.create(chart.key, new SeasonParams().socialDistancingRulesetKey('ruleset1'))
|
|
74
70
|
|
|
75
|
-
expect(season.
|
|
71
|
+
expect(season.socialDistancingRulesetKey).toBe('ruleset1')
|
|
76
72
|
})
|
|
@@ -16,14 +16,10 @@ test('retrieve season', async () => {
|
|
|
16
16
|
expect(retrievedSeason.id).toBeTruthy()
|
|
17
17
|
expect(retrievedSeason.partialSeasonKeys).toEqual([partialSeason1.key, partialSeason2.key])
|
|
18
18
|
expect(retrievedSeason.events.map(e => e.key)).toEqual(['event1', 'event2'])
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
expect(
|
|
22
|
-
expect(
|
|
23
|
-
expect(
|
|
24
|
-
expect(
|
|
25
|
-
expect(seasonEvent.supportsBestAvailable).toBe(true)
|
|
26
|
-
expect(seasonEvent.createdOn).toBeInstanceOf(Date)
|
|
27
|
-
expect(seasonEvent.forSaleConfig).toBeFalsy()
|
|
28
|
-
expect(seasonEvent.updatedOn).toBeFalsy()
|
|
19
|
+
expect(retrievedSeason.chartKey).toBe(chartKey)
|
|
20
|
+
expect(retrievedSeason.tableBookingConfig).toEqual(TableBookingConfig.inherit())
|
|
21
|
+
expect(retrievedSeason.supportsBestAvailable).toBe(true)
|
|
22
|
+
expect(retrievedSeason.createdOn).toBeInstanceOf(Date)
|
|
23
|
+
expect(retrievedSeason.forSaleConfig).toBeFalsy()
|
|
24
|
+
expect(retrievedSeason.updatedOn).toBeFalsy()
|
|
29
25
|
})
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const testUtils = require('../testUtils.js')
|
|
2
|
-
|
|
3
|
-
test('delete partial season', async () => {
|
|
4
|
-
const { client, user } = await testUtils.createTestUserAndClient()
|
|
5
|
-
const chartKey = testUtils.getChartKey()
|
|
6
|
-
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
7
|
-
const season = await client.seasons.create(chartKey)
|
|
8
|
-
const partialSeason = await client.seasons.createPartialSeason(season.key)
|
|
9
|
-
|
|
10
|
-
await client.seasons.deletePartialSeason(season.key, partialSeason.key)
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
await client.seasons.retrievePartialSeason(season.key, partialSeason.key)
|
|
14
|
-
throw new Error('Should have failed')
|
|
15
|
-
} catch (e) {
|
|
16
|
-
expect(e.errors[0].code).toBe('SEASON_NOT_FOUND')
|
|
17
|
-
}
|
|
18
|
-
})
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const testUtils = require('../testUtils.js')
|
|
2
|
-
|
|
3
|
-
test('delete season', async () => {
|
|
4
|
-
const { client, user } = await testUtils.createTestUserAndClient()
|
|
5
|
-
const chartKey = testUtils.getChartKey()
|
|
6
|
-
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
7
|
-
const season = await client.seasons.create(chartKey)
|
|
8
|
-
|
|
9
|
-
await client.seasons.delete(season.key)
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
await client.seasons.retrieve(season.key)
|
|
13
|
-
throw new Error('Should have failed')
|
|
14
|
-
} catch (e) {
|
|
15
|
-
expect(e.errors[0].code).toBe('SEASON_NOT_FOUND')
|
|
16
|
-
}
|
|
17
|
-
})
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const testUtils = require('../testUtils.js')
|
|
2
|
-
|
|
3
|
-
test('list all seasons', async () => {
|
|
4
|
-
const { client } = await testUtils.createTestUserAndClient()
|
|
5
|
-
const chart = await client.charts.create()
|
|
6
|
-
const season1 = await client.seasons.create(chart.key)
|
|
7
|
-
const season2 = await client.seasons.create(chart.key)
|
|
8
|
-
const season3 = await client.seasons.create(chart.key)
|
|
9
|
-
|
|
10
|
-
const retrievedSeasonKeys = []
|
|
11
|
-
for await (const season of client.seasons.listAll()) {
|
|
12
|
-
retrievedSeasonKeys.push(season.key)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
expect(retrievedSeasonKeys).toEqual([season3.key, season2.key, season1.key])
|
|
16
|
-
})
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const testUtils = require('../testUtils.js')
|
|
2
|
-
const TableBookingConfig = require('../../src/Events/TableBookingConfig')
|
|
3
|
-
|
|
4
|
-
test('retrieve partial season', async () => {
|
|
5
|
-
const { client, user } = await testUtils.createTestUserAndClient()
|
|
6
|
-
const chartKey = testUtils.getChartKey()
|
|
7
|
-
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
8
|
-
const season = await client.seasons.create(chartKey)
|
|
9
|
-
const partialSeason = await client.seasons.createPartialSeason(season.key)
|
|
10
|
-
|
|
11
|
-
const retrievedPartialSeason = await client.seasons.retrievePartialSeason(season.key, partialSeason.key)
|
|
12
|
-
|
|
13
|
-
expect(retrievedPartialSeason.key).toBe(partialSeason.key)
|
|
14
|
-
expect(retrievedPartialSeason.id).toBeTruthy()
|
|
15
|
-
|
|
16
|
-
const seasonEvent = retrievedPartialSeason.seasonEvent
|
|
17
|
-
expect(seasonEvent.id).toBeTruthy()
|
|
18
|
-
expect(seasonEvent.key).toBe(retrievedPartialSeason.key)
|
|
19
|
-
expect(seasonEvent.chartKey).toBe(chartKey)
|
|
20
|
-
expect(seasonEvent.tableBookingConfig).toEqual(TableBookingConfig.inherit())
|
|
21
|
-
expect(seasonEvent.supportsBestAvailable).toBe(true)
|
|
22
|
-
expect(seasonEvent.createdOn).toBeInstanceOf(Date)
|
|
23
|
-
expect(seasonEvent.forSaleConfig).toBeFalsy()
|
|
24
|
-
expect(seasonEvent.updatedOn).toBeFalsy()
|
|
25
|
-
})
|