mirror of
https://github.com/filiprojek/nork.git
synced 2025-02-20 01:22:58 +01:00
rewriting to oop and typescript
This commit is contained in:
23
src/tests/help.test.ts
Normal file
23
src/tests/help.test.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { assert } from 'chai'
|
||||
import Help from '../help'
|
||||
import pad from 'pad'
|
||||
|
||||
describe('should return help', () => {
|
||||
it('returns all help', () => {
|
||||
const help = Help.logHelp()
|
||||
const correct = Help.allHelp()
|
||||
assert.equal(help, correct)
|
||||
})
|
||||
|
||||
it('returns make help', () => {
|
||||
const help = Help.logHelp('make')
|
||||
const correct = Help.makeHelp()
|
||||
assert.equal(help, correct)
|
||||
})
|
||||
|
||||
it('returns specific help', () => {
|
||||
const help = Help.logHelp('setup')
|
||||
const correct = Help.specificHelp('setup')
|
||||
assert.equal(help, correct)
|
||||
})
|
||||
})
|
||||
58
src/tests/router.test.ts
Normal file
58
src/tests/router.test.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { assert } from 'chai'
|
||||
import Routes from '../routes'
|
||||
|
||||
describe('should return help', () => {
|
||||
process.argv = []
|
||||
it('return all help', () => {
|
||||
const options = ['-h', '--help']
|
||||
for (let i = 0; i < options.length; i++) {
|
||||
process.argv[2] = options[i]
|
||||
process.argv[3] = ''
|
||||
const routes = Routes.router()
|
||||
assert.equal(routes, 'all help')
|
||||
}
|
||||
})
|
||||
|
||||
it('return specific help', () => {
|
||||
const options = ['-h', '--help']
|
||||
for (let i = 0; i < options.length; i++) {
|
||||
process.argv[2] = options[i]
|
||||
process.argv[3] = 'make'
|
||||
const routes = Routes.router()
|
||||
assert.equal(routes, 'specific help')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('should return version', () => {
|
||||
it('return version', () => {
|
||||
const options = ['-v', '--version']
|
||||
for (let i = 0; i < options.length; i++) {
|
||||
process.argv[2] = options[i]
|
||||
const routes = Routes.router()
|
||||
assert.equal(routes, 'version')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('should return setup', () => {
|
||||
it('return setup', () => {
|
||||
process.argv[2] = 'setup'
|
||||
process.argv[3] = 'test'
|
||||
const routes = Routes.router()
|
||||
assert.equal(routes, 'setup')
|
||||
})
|
||||
})
|
||||
|
||||
describe('should return make', () => {
|
||||
const options = ['controller', 'middleware', 'route', 'service', 'model', 'view', 'test', 'interface']
|
||||
for (let i = 0; i < options.length; i++) {
|
||||
it(`return make ${options[i]}`, () => {
|
||||
process.argv[2] = 'make'
|
||||
process.argv[3] = options[i]
|
||||
process.argv[4] = 'test'
|
||||
const routes = Routes.router()
|
||||
assert.equal(routes, `make ${options[i]}`)
|
||||
})
|
||||
}
|
||||
})
|
||||
11
src/tests/setup.test.ts
Normal file
11
src/tests/setup.test.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { assert } from 'chai'
|
||||
import Setup from '../setup'
|
||||
import Global from '../global'
|
||||
|
||||
describe('should setup project', () => {
|
||||
it('setup project', async () => {
|
||||
const correct: string = Global.logSuccess()
|
||||
const setup = await Setup.setup(true)
|
||||
assert.equal(setup, correct)
|
||||
})
|
||||
})
|
||||
20
src/tests/test.test.ts.old
Normal file
20
src/tests/test.test.ts.old
Normal file
@@ -0,0 +1,20 @@
|
||||
import { assert } from 'chai'
|
||||
import { App } from '../app'
|
||||
|
||||
// Describe tests
|
||||
describe('some demo tests', () => {
|
||||
// Create tests
|
||||
it('adds two number together', () => {
|
||||
assert(2 + 3 === 5)
|
||||
})
|
||||
|
||||
it('should return Hello plus my name', () => {
|
||||
assert.equal(App.sayHello('Filip'), 'Hello Filip')
|
||||
assert.notEqual(App.sayHello('Adam'), 'Hello Filip')
|
||||
})
|
||||
|
||||
it('should return Hello plus my name within instance', () => {
|
||||
const app = new App('Filip')
|
||||
assert.equal(app.pozdrav(), 'Hello Filip')
|
||||
})
|
||||
})
|
||||
11
src/tests/version.test.ts
Normal file
11
src/tests/version.test.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { assert } from 'chai'
|
||||
import Version from '../version'
|
||||
import path from 'path'
|
||||
|
||||
describe('should return version', () => {
|
||||
it('return version', () => {
|
||||
const pkgJson = require(path.join(__dirname, '../../package'))
|
||||
const actualVersion = pkgJson.version
|
||||
assert.equal(Version.show(), `nork ${actualVersion}`)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user