-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Erick Wendel <erick.workspace@gmail.com>
- Loading branch information
1 parent
42017ce
commit 2c9cec0
Showing
6 changed files
with
104 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
// { | ||
// "type": "node", | ||
// "request": "launch", | ||
// "name": "Run CLI Debugger", | ||
// "runtimeExecutable": "npm", | ||
// "runtimeArgs": [ | ||
// "run", | ||
// "cli:dev" | ||
// ], | ||
// "cwd": "${fileDirname}", | ||
// "skipFiles": [ | ||
// "<node_internals>/**/**", | ||
// "node_modules/**/**", | ||
// ], | ||
// "console": "integratedTerminal" | ||
// }, | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Run Test Debugger", | ||
"runtimeExecutable": "npm", | ||
"runtimeArgs": [ | ||
"run", | ||
"test:dev" | ||
], | ||
"cwd": "${fileDirname}", | ||
"skipFiles": [ | ||
"<node_internals>/**/**", | ||
"node_modules/**/**", | ||
], | ||
"console": "integratedTerminal" | ||
} | ||
], | ||
"compounds": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,57 @@ | ||
import Controller from "../src/shared/controller.js"; | ||
import View from '../src/platforms/console/view.js'; | ||
// import Controller from "../src/shared/controller.js"; | ||
// import View from '../src/platforms/console/view.js'; | ||
|
||
import { describe, it, before } from 'node:test'; | ||
import assert from 'node:assert'; | ||
// import { describe, it, before } from 'node:test'; | ||
// import assert from 'node:assert'; | ||
|
||
import blessed from 'blessed'; | ||
import contrib from 'blessed-contrib'; | ||
import { overrideModules } from "./_helpers/mockImports.js"; | ||
// import blessed from 'blessed'; | ||
// import contrib from 'blessed-contrib'; | ||
// import { overrideModules } from "./_helpers/mockImports.js"; | ||
|
||
describe('CLI Test Suite', () => { | ||
before(() => { | ||
overrideModules([blessed, contrib]); | ||
}); | ||
// describe('CLI Test Suite', () => { | ||
// before(() => { | ||
// overrideModules([blessed, contrib]); | ||
// }); | ||
|
||
it('should initialize blessed, submit a form, add row and clean up form', async (context) => { | ||
const view = new View(); | ||
// it('should initialize blessed, submit a form, add row and clean up form', async (context) => { | ||
// const view = new View(); | ||
|
||
const screenMock = context.mock.method(blessed, "screen"); | ||
const tableMockMock = context.mock.method(contrib, "table"); | ||
// const screenMock = context.mock.method(blessed, "screen"); | ||
// const tableMockMock = context.mock.method(contrib, "table"); | ||
|
||
const onSubmit = context.mock.fn() | ||
const onReset = context.mock.fn() | ||
// const onSubmit = context.mock.fn() | ||
// const onReset = context.mock.fn() | ||
|
||
context.mock.method(blessed, 'form', (...args) => { | ||
return { | ||
on: onSubmit, | ||
reset: onReset | ||
} | ||
}) | ||
// context.mock.method(blessed, 'form', (...args) => { | ||
// return { | ||
// on: onSubmit, | ||
// reset: onReset | ||
// } | ||
// }) | ||
|
||
const addRow = context.mock.method(view, view.addRow.name); | ||
const resetForm = context.mock.method(view, view.resetForm.name); | ||
// const addRow = context.mock.method(view, view.addRow.name); | ||
// const resetForm = context.mock.method(view, view.resetForm.name); | ||
|
||
await Controller.init({ view: view }); | ||
// await Controller.init({ | ||
// view: view, | ||
// service: { | ||
// createUser: context.mock.fn(), | ||
// getUsers: context.mock.fn(async () => []), | ||
// } | ||
// }); | ||
|
||
assert.strictEqual(screenMock.mock.callCount(), 1); | ||
assert.strictEqual(tableMockMock.mock.callCount(), 1); | ||
// assert.strictEqual(screenMock.mock.callCount(), 1); | ||
// assert.strictEqual(tableMockMock.mock.callCount(), 1); | ||
|
||
const onSubmitMock = onSubmit.mock | ||
assert.strictEqual(onSubmitMock.callCount(), 1); | ||
// const onSubmitMock = onSubmit.mock | ||
// assert.strictEqual(onSubmitMock.callCount(), 1); | ||
|
||
const onSubmitFn = onSubmitMock.calls[0].arguments[1] | ||
const data = { name: 'Erick Wendel', age: 28, email: 'e@e.com' } | ||
onSubmitFn(data) | ||
// const onSubmitFn = onSubmitMock.calls[0].arguments[1] | ||
// const data = { name: 'Erick Wendel', age: 28, email: 'e@e.com' } | ||
// onSubmitFn(data) | ||
|
||
assert.strictEqual(addRow.mock.callCount(), 1) | ||
assert.strictEqual(resetForm.mock.callCount(), 1) | ||
// assert.strictEqual(addRow.mock.callCount(), 1) | ||
// assert.strictEqual(resetForm.mock.callCount(), 1) | ||
|
||
}); | ||
}); | ||
// }); | ||
// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters