Created
June 21, 2018 12:29
-
-
Save MartinMuzatko/d5f96f136732391b8ba52560f829e57f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import test from 'ava' | |
| import apps from './apps' | |
| import promisify from 'promisify-node' | |
| const fs = promisify('fs') | |
| const constants = require('./constants'); | |
| test.before(async t => { | |
| await fs.copyFile(constants.STATICSERVERSCONFIGPATH, constants.STATICSERVERSCONFIGPATH+'.backup') | |
| }) | |
| test('listing apps with their enriched data objects', async t => { | |
| let servers = await apps.list() | |
| t.true(Array.isArray(servers)) | |
| t.true('url' in servers[0]) | |
| }) | |
| test('Try to set a default app that does not exist', async t => { | |
| await t.throws(apps.setDefault('I do not exist')) | |
| }) | |
| test('Set default app', async t => { | |
| let newDefault = 'config' | |
| await apps.setDefault(newDefault) | |
| let defaultApp = await apps.getDefault() | |
| t.is(defaultApp.pathname, newDefault) | |
| }) | |
| test('get default app', async t => { | |
| let defaultApp = await apps.getDefault() | |
| t.is(typeof defaultApp, 'object') | |
| }) | |
| test('create app with invalid params throws error', async t => { | |
| await t.throws(apps.create()) | |
| }) | |
| test('creating an app that already exists throws an error', async t => { | |
| await t.throws(apps.create({ | |
| pathname: 'cockpit', // only pathname has to be unique | |
| path: './frontend', | |
| name: 'Test App', | |
| })) | |
| }) | |
| test('update an existing app', async t => { | |
| await t.notThrows(apps.update( | |
| 'apidocs', | |
| { | |
| pathname: 'restapi' | |
| } | |
| )) | |
| }) | |
| test('create app', async t => { | |
| let x = await apps.create({ | |
| pathname: 'test', | |
| path: './frontend', | |
| name: 'Test App', | |
| }) | |
| t.is(x, x) | |
| }) | |
| test.after.always(async t => { | |
| await fs.copyFile(constants.STATICSERVERSCONFIGPATH + '.backup', constants.STATICSERVERSCONFIGPATH) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment