Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ Good next steps:
1. Get a demo script of creating some tables w the meta api
2. Get export working
3. Get boilerplate (lql init) working
4. Get testing framework working (this will be HUGE)
4. Get testing framework working (this will be HUGE)



**** MOVE postgraphile-<plugin>s over
62 changes: 62 additions & 0 deletions packages/cli/__tests__/__snapshots__/cli.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Inquirerer prompts user and correctly processes delayed input 1`] = `
{
"autocompleteField": "firry third option",
}
`;

exports[`Inquirerer prompts user and correctly processes delayed input 2`] = `
{
"autocompleteField": "firry third option",
}
`;

exports[`Inquirerer prompts user and correctly processes delayed input 3`] = `
[
"",
"autocompleteField?
Argument<SPACE>--autocompleteField<SPACE>type<SPACE>[autocomplete]
><SPACE>Your<SPACE>input:
$<SPACE>
",
"><SPACE>first<SPACE>option
",
"<SPACE><SPACE>firry<SPACE>second<SPACE>option
",
"<SPACE><SPACE>firry<SPACE>third<SPACE>option
",
"",
"autocompleteField?
Argument<SPACE>--autocompleteField<SPACE>type<SPACE>[autocomplete]
><SPACE>Your<SPACE>input:
$<SPACE>
",
"<SPACE><SPACE>first<SPACE>option
",
"><SPACE>firry<SPACE>second<SPACE>option
",
"<SPACE><SPACE>firry<SPACE>third<SPACE>option
",
"",
"autocompleteField?
Argument<SPACE>--autocompleteField<SPACE>type<SPACE>[autocomplete]
><SPACE>Your<SPACE>input:
$<SPACE>
",
"<SPACE><SPACE>first<SPACE>option
",
"<SPACE><SPACE>firry<SPACE>second<SPACE>option
",
"><SPACE>firry<SPACE>third<SPACE>option
",
]
`;

exports[`Inquirerer prompts user and correctly processes delayed input 4`] = `
[
"",
"",
"<ENTER>",
]
`;
87 changes: 87 additions & 0 deletions packages/cli/__tests__/__snapshots__/extensions.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`extension runs \`extension\` command after workspace and module setup: extension-update - files 1`] = `
[
"__tests__/first.test.ts",
".questions.json",
"jest.config.js",
"Makefile",
"my-module.control",
"package.json",
"README.md",
"sqitch.conf",
"sqitch.plan",
"src/index.ts",
"tsconfig.esm.json",
"tsconfig.json",
]
`;

exports[`extension runs \`extension\` command after workspace and module setup: extension-update - result 1`] = `
{
"_": [
"extension",
],
"cwd": "<CWD>",
"extensions": [
"plpgsql",
"module-c",
],
}
`;

exports[`extension runs \`extension\` command after workspace and module setup: initial - control file 1`] = `
"# my-module extension
comment = 'my-module extension'
default_version = '0.0.1'
module_pathname = '$libdir/my-module'
requires = 'mod-1,mod2'
relocatable = false
superuser = false
"
`;

exports[`extension runs \`extension\` command after workspace and module setup: initial - module dependencies 1`] = `
{
"modules": [],
"native": [
"mod-1",
"mod2",
],
}
`;

exports[`extension runs \`extension\` command after workspace and module setup: initial - required modules 1`] = `
[
"mod-1",
"mod2",
]
`;

exports[`extension runs \`extension\` command after workspace and module setup: updated - control file 1`] = `
"# my-module extension
comment = 'my-module extension'
default_version = '0.0.1'
module_pathname = '$libdir/my-module'
requires = 'plpgsql,module-c'
relocatable = false
superuser = false
"
`;

exports[`extension runs \`extension\` command after workspace and module setup: updated - module dependencies 1`] = `
{
"modules": [],
"native": [
"plpgsql",
"module-c",
],
}
`;

exports[`extension runs \`extension\` command after workspace and module setup: updated - required modules 1`] = `
[
"plpgsql",
"module-c",
]
`;
122 changes: 122 additions & 0 deletions packages/cli/__tests__/__snapshots__/init.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`init initialize module 1`] = `
"# my-module extension
comment = 'my-module extension'
default_version = '0.0.1'
module_pathname = '$libdir/my-module'
requires = 'citext,plpgsql'
relocatable = false
superuser = false
"
`;

exports[`init initialize module: module-only - argv 1`] = `
{
"MODULENAME": "my-module",
"_": [
"init",
],
"cwd": "<CWD>",
"extensions": [
"plpgsql",
"citext",
],
"name": "my-module",
}
`;

exports[`init initialize module: module-only - files 1`] = `
[
".eslintrc.json",
".gitignore",
".prettierrc.json",
".questions.json",
"bin/install.sh",
"bootstrap-roles.sql",
"docker-compose.yml",
"launchql.json",
"lerna.json",
"LICENSE",
"Makefile",
"package.json",
"packages/my-module/__tests__/first.test.ts",
"packages/my-module/.questions.json",
"packages/my-module/jest.config.js",
"packages/my-module/Makefile",
"packages/my-module/my-module.control",
"packages/my-module/package.json",
"packages/my-module/README.md",
"packages/my-module/sqitch.conf",
"packages/my-module/sqitch.plan",
"packages/my-module/src/index.ts",
"packages/my-module/tsconfig.esm.json",
"packages/my-module/tsconfig.json",
"README.md",
"tsconfig.json",
]
`;

exports[`init initialize module: module-only - result 1`] = `
{
"MODULENAME": "my-module",
"_": [
"init",
],
"cwd": "<CWD>",
"extensions": [
"plpgsql",
"citext",
],
"name": "my-module",
}
`;

exports[`init initialize module: module-only - transformResults 1`] = `[]`;

exports[`init initialize module: module-only - writeResults 1`] = `[]`;

exports[`init initializes workspace: workspace - argv 1`] = `
{
"_": [
"init",
],
"cwd": "<CWD>",
"name": "my-workspace",
"workspace": true,
}
`;

exports[`init initializes workspace: workspace - files 1`] = `
[
"my-workspace/.eslintrc.json",
"my-workspace/.gitignore",
"my-workspace/.prettierrc.json",
"my-workspace/.questions.json",
"my-workspace/bin/install.sh",
"my-workspace/bootstrap-roles.sql",
"my-workspace/docker-compose.yml",
"my-workspace/launchql.json",
"my-workspace/lerna.json",
"my-workspace/LICENSE",
"my-workspace/Makefile",
"my-workspace/package.json",
"my-workspace/README.md",
"my-workspace/tsconfig.json",
]
`;

exports[`init initializes workspace: workspace - result 1`] = `
{
"_": [
"init",
],
"cwd": "<CWD>",
"name": "my-workspace",
"workspace": true,
}
`;

exports[`init initializes workspace: workspace - transformResults 1`] = `[]`;

exports[`init initializes workspace: workspace - writeResults 1`] = `[]`;
42 changes: 42 additions & 0 deletions packages/cli/__tests__/cli.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Inquirerer, Question } from 'inquirerer';
import { KEY_SEQUENCES, setupTests, TestEnvironment } from '../test-utils';

const beforeEachSetup = setupTests();

describe('Inquirerer', () => {
let environment: TestEnvironment;

beforeEach(() => {
environment = beforeEachSetup();
});

it('prompts user and correctly processes delayed input', async () => {
const { mockInput, mockOutput, writeResults, transformResults, enqueueInputResponse } = environment;

const prompter = new Inquirerer({
input: mockInput,
output: mockOutput,
noTty: false
});

const questions: Question[] = [{
name: 'autocompleteField',
type: 'autocomplete',
options: ['first option', 'firry second option', 'firry third option']
}];

const argv = {};

enqueueInputResponse({ type: 'read', value: 'fir' });
enqueueInputResponse({ type: 'key', value: KEY_SEQUENCES.DOWN_ARROW });
enqueueInputResponse({ type: 'key', value: KEY_SEQUENCES.DOWN_ARROW });
enqueueInputResponse({ type: 'key', value: KEY_SEQUENCES.ENTER });

const result = await prompter.prompt(argv, questions);

expect(argv).toMatchSnapshot();
expect(result).toMatchSnapshot();
expect(writeResults).toMatchSnapshot();
expect(transformResults).toMatchSnapshot();
});
});
Loading