mirror of
https://github.com/olehomelchenko/astrolabe.git
synced 2026-08-08 02:02:33 +00:00
Shell: one-shot #example-<id> deep link consumed at startup
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import {
|
||||
parseHash,
|
||||
parseExampleHash,
|
||||
serializeHash,
|
||||
readView,
|
||||
replaceView,
|
||||
@@ -75,6 +76,24 @@ describe('parseHash', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseExampleHash', () => {
|
||||
it('extracts the example id from the one-shot action link', () => {
|
||||
expect(parseExampleHash('#example-brush')).toBe('brush');
|
||||
expect(parseExampleHash('example-bar')).toBe('bar'); // leading "#" optional
|
||||
});
|
||||
|
||||
it('returns null for anything that is not an example link', () => {
|
||||
expect(parseExampleHash('')).toBeNull();
|
||||
expect(parseExampleHash('#example-')).toBeNull(); // empty id
|
||||
expect(parseExampleHash('#snippet-abc')).toBeNull();
|
||||
expect(parseExampleHash('#build')).toBeNull();
|
||||
});
|
||||
|
||||
it('is not a ViewState: parseHash degrades an example link to the default view', () => {
|
||||
expect(parseHash('#example-brush')).toEqual({ kind: 'snippets' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('round-trip identity', () => {
|
||||
it('parseHash(serializeHash(v)) deep-equals v for every variant', () => {
|
||||
for (const v of ALL_VIEWS) {
|
||||
|
||||
Reference in New Issue
Block a user