|
| 1 | +import SpaceSchema from '@snapshot-labs/snapshot.js/src/schemas/space.json'; |
1 | 2 | import { verify } from '../../../src/writer/settings';
|
2 | 3 | import { spacesGetSpaceFixtures } from '../../fixtures/space';
|
3 | 4 | import input from '../../fixtures/writer-payload/space.json';
|
4 |
| -import SpaceSchema from '@snapshot-labs/snapshot.js/src/schemas/space.json'; |
5 | 5 |
|
6 | 6 | function editedInput(payload = {}) {
|
7 | 7 | const result = { ...input, msg: JSON.parse(input.msg) };
|
@@ -105,6 +105,70 @@ describe('writer/settings', () => {
|
105 | 105 | )
|
106 | 106 | ).rejects.toContain('wrong space format');
|
107 | 107 | });
|
| 108 | + |
| 109 | + describe('when the space has an existing custom domain', () => { |
| 110 | + it('accepts a new domain for non-turbo spaces', () => { |
| 111 | + mockGetSpace.mockResolvedValueOnce({ |
| 112 | + ...spacesGetSpaceFixtures, |
| 113 | + turbo: false, |
| 114 | + domain: 'test.com' |
| 115 | + }); |
| 116 | + return expect( |
| 117 | + verify( |
| 118 | + editedInput({ |
| 119 | + domain: 'test2.com' |
| 120 | + }) |
| 121 | + ) |
| 122 | + ).resolves.toBeUndefined(); |
| 123 | + }); |
| 124 | + |
| 125 | + it('accepts a new domain for turbo spaces', () => { |
| 126 | + mockGetSpace.mockResolvedValueOnce({ |
| 127 | + ...spacesGetSpaceFixtures, |
| 128 | + turbo: true, |
| 129 | + domain: 'test.com' |
| 130 | + }); |
| 131 | + return expect( |
| 132 | + verify( |
| 133 | + editedInput({ |
| 134 | + domain: 'test2.com' |
| 135 | + }) |
| 136 | + ) |
| 137 | + ).resolves.toBeUndefined(); |
| 138 | + }); |
| 139 | + }); |
| 140 | + |
| 141 | + describe('when the space does not have an existing custom domain', () => { |
| 142 | + it('rejects a new domain for non-turbo spaces', () => { |
| 143 | + mockGetSpace.mockResolvedValueOnce({ |
| 144 | + ...spacesGetSpaceFixtures, |
| 145 | + turbo: false, |
| 146 | + domain: undefined |
| 147 | + }); |
| 148 | + return expect( |
| 149 | + verify( |
| 150 | + editedInput({ |
| 151 | + domain: 'test2.com' |
| 152 | + }) |
| 153 | + ) |
| 154 | + ).rejects.toContain('domain is a turbo feature only'); |
| 155 | + }); |
| 156 | + |
| 157 | + it('accepts a new domain for turbo spaces', () => { |
| 158 | + mockGetSpace.mockResolvedValueOnce({ |
| 159 | + ...spacesGetSpaceFixtures, |
| 160 | + turbo: true, |
| 161 | + domain: undefined |
| 162 | + }); |
| 163 | + return expect( |
| 164 | + verify( |
| 165 | + editedInput({ |
| 166 | + domain: 'test2.com' |
| 167 | + }) |
| 168 | + ) |
| 169 | + ).resolves.toBeUndefined(); |
| 170 | + }); |
| 171 | + }); |
108 | 172 | });
|
109 | 173 |
|
110 | 174 | describe('on valid data', () => {
|
|
0 commit comments