@labdigital/commercetools-mock 2.2.0 → 2.4.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.
@@ -48,6 +48,105 @@ describe('Categories Query', () => {
48
48
  })
49
49
  })
50
50
 
51
+ describe('categories changeName', () => {
52
+ const ctMock = new CommercetoolsMock()
53
+ let category: Category | undefined
54
+
55
+ beforeEach(async () => {
56
+ const response = await supertest(ctMock.app)
57
+ .post('/dummy/categories')
58
+ .send({
59
+ name: {
60
+ en: 'Top hat',
61
+ },
62
+ slug: {
63
+ en: 'top-hat',
64
+ },
65
+ orderHint: '0.1',
66
+ })
67
+ expect(response.status).toBe(201)
68
+ category = response.body as Category
69
+ })
70
+
71
+ test('changeName', async () => {
72
+ const changeNameResponse = await supertest(ctMock.app)
73
+ .post(`/dummy/categories/${category?.id}`)
74
+ .send({
75
+ version: 1,
76
+ actions: [
77
+ {
78
+ action: 'changeName',
79
+ name: {
80
+ en: 'Top hat - new name',
81
+ },
82
+ },
83
+ ],
84
+ })
85
+
86
+ expect(changeNameResponse.status).toBe(200)
87
+ expect(changeNameResponse.body.name.en).toBe('Top hat - new name')
88
+ })
89
+ })
90
+
91
+ describe('categories changeParent', () => {
92
+ const ctMock = new CommercetoolsMock()
93
+ let category1: Category | undefined
94
+ let category2: Category | undefined
95
+
96
+ beforeEach(async () => {
97
+ const response1 = await supertest(ctMock.app)
98
+ .post('/dummy/categories')
99
+ .send({
100
+ name: {
101
+ en: 'Top hat',
102
+ },
103
+ slug: {
104
+ en: 'top-hat',
105
+ },
106
+ orderHint: '0.1',
107
+ })
108
+ expect(response1.status).toBe(201)
109
+ category1 = response1.body as Category
110
+
111
+ const response2 = await supertest(ctMock.app)
112
+ .post('/dummy/categories')
113
+ .send({
114
+ name: {
115
+ en: 'Top hat',
116
+ },
117
+ slug: {
118
+ en: 'top-hat',
119
+ },
120
+ orderHint: '0.1',
121
+ })
122
+ expect(response2.status).toBe(201)
123
+ category2 = response2.body as Category
124
+ })
125
+
126
+ test('changeParent', async () => {
127
+ const changeNameResponse = await supertest(ctMock.app)
128
+ .post(`/dummy/categories/${category2?.id}`)
129
+ .send({
130
+ version: 1,
131
+ actions: [
132
+ {
133
+ action: 'changeParent',
134
+ parent: {
135
+ typeId: 'category',
136
+ id: category1?.id,
137
+ },
138
+ },
139
+ ],
140
+ })
141
+
142
+ expect(changeNameResponse.status).toBe(200)
143
+ expect(changeNameResponse.body.parent).toEqual({
144
+ typeId: 'category',
145
+ id: category1?.id,
146
+ })
147
+ })
148
+ })
149
+
51
150
  describe('Categories add asset', () => {
52
151
  const ctMock = new CommercetoolsMock()
53
152
  let category: Category | undefined