|
| 1 | +import test from 'tape'; |
| 2 | +import {getQueryParameters} from '../../../src/util/queryParams'; |
| 3 | + |
| 4 | + |
| 5 | +test('empty querystring', (assert) => { |
| 6 | + const {gistId, snapshotKey, isExperimental} = getQueryParameters(''); |
| 7 | + assert.isEqual(gistId, null); |
| 8 | + assert.isEqual(snapshotKey, null); |
| 9 | + assert.isEqual(isExperimental, false); |
| 10 | + assert.end(); |
| 11 | +}); |
| 12 | + |
| 13 | +test('snapshot url', (assert) => { |
| 14 | + const { |
| 15 | + gistId, |
| 16 | + snapshotKey, |
| 17 | + isExperimental, |
| 18 | + } = getQueryParameters('?snapshot=90283083-5951-4af8-bc12-2fe889ea5e4a'); |
| 19 | + assert.isEqual(gistId, null); |
| 20 | + assert.isEqual(snapshotKey, '90283083-5951-4af8-bc12-2fe889ea5e4a'); |
| 21 | + assert.isEqual(isExperimental, false); |
| 22 | + assert.end(); |
| 23 | +}); |
| 24 | + |
| 25 | + |
| 26 | +test('experimental url', (assert) => { |
| 27 | + const { |
| 28 | + gistId, |
| 29 | + snapshotKey, |
| 30 | + isExperimental, |
| 31 | + } = getQueryParameters('?experimental'); |
| 32 | + assert.isEqual(gistId, null); |
| 33 | + assert.isEqual(snapshotKey, null); |
| 34 | + assert.isEqual(isExperimental, true); |
| 35 | + assert.end(); |
| 36 | +}); |
| 37 | + |
| 38 | +test('gist url', (assert) => { |
| 39 | + const { |
| 40 | + gistId, |
| 41 | + snapshotKey, |
| 42 | + isExperimental, |
| 43 | + } = getQueryParameters('?gist=223f7869fa7dea6089dffd72a38c3286'); |
| 44 | + assert.isEqual(gistId, '223f7869fa7dea6089dffd72a38c3286'); |
| 45 | + assert.isEqual(snapshotKey, null); |
| 46 | + assert.isEqual(isExperimental, false); |
| 47 | + assert.end(); |
| 48 | +}); |
0 commit comments