1import getDefaultScheme from '../getDefaultScheme';
2
3it(`generates a valid URI scheme from slug`, () => {
4  expect(getDefaultScheme({ slug: 'hello-world' })).toMatchInlineSnapshot(`"exp+hello-world"`);
5  expect(getDefaultScheme({ slug: 'my app 2000' })).toMatchInlineSnapshot(`"exp+myapp2000"`);
6  expect(getDefaultScheme({ slug: 'Yolo ¯\\_(ツ)_/¯' })).toMatchInlineSnapshot(`"exp+yolo"`);
7});
8
9it(`removes unallowed characters`, () => {
10  // scheme      = ALPHA *( ALPHA /` DIGIT / "+" / "-" / "." )
11  expect(getDefaultScheme({ slug: 'miun äppi!1!!!!!@' })).toMatch(/^[A-Za-z][A-Za-z0-9+\-.]*/);
12});
13
14it(`doesn't start with a number or special character`, () => {
15  // scheme      = ALPHA *( ALPHA /` DIGIT / "+" / "-" / "." )
16  expect(getDefaultScheme({ slug: '650-industries' })).toMatch(/^[A-Za-z][A-Za-z0-9+\-.]*/);
17});
18
19it(`bails out if there aren't any ASCII characters in the slug to work with`, () => {
20  expect(() => getDefaultScheme({ slug: '��' })).toThrowErrorMatchingInlineSnapshot(
21    `"Could not autogenerate a scheme. Please make sure the "slug" property in app config consists of URL friendly characters."`
22  );
23});
24