From 72dfa17df48760efb399e1d6e9c946d8870a2b6b Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 7 Oct 2017 17:48:05 +0400 Subject: Full-featured testing --- src/tests/index.js | 54 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/src/tests/index.js b/src/tests/index.js index 176d192..a76813a 100644 --- a/src/tests/index.js +++ b/src/tests/index.js @@ -3,27 +3,59 @@ import { assert } from 'chai'; import Containers from '../lib/index'; describe('simple-container:', () => { + var image = 'alpine:latest'; + var containers = null; var container = null; - before((done) => { - var containers = new Containers(); - var image = 'hello-world:latest'; + before(() => { + containers = new Containers(); + }); - containers.create(image).then(item => { + after((done) => { + /* Removing the container after testing */ + container.remove().then(() => { + done(); + }); + }); + + it('create(image)', (done) => { + containers.create(image).then((item) => { + assert.isObject(item); container = item; done(); }); }); - after((done) => { - container.stop(() => { - container.remove(() => { - done(); - }); + it('info(id)', (done) => { + containers.info(container.id).then((item) => { + assert.equal(item.Id, container.id); + assert.equal(item.Image, image); + assert.isObject(item); + done(); + }); + }); + + it('info()', (done) => { + containers.info().then((list) => { + var item = list[container.id]; + assert.equal(item.Id, container.id); + assert.equal(item.Image, image); + assert.isObject(item); + done(); }); }); - it('simple', () => { - assert.isString(container.id); + it('get(id)', (done) => { + containers.get(container.id).then((item) => { + assert.deepEqual(container, item); + done(); + }); + }); + + it('get()', (done) => { + containers.get().then((list) => { + assert.deepEqual(container, list[container.id]); + done(); + }); }); }); \ No newline at end of file -- cgit v1.2.3