3 var DB = require('../../server/class/DB');
4 var chai = require('chai');
5 var chaiAsPromised = require('chai-as-promised');
6 chai.use(chaiAsPromised);
7 var expect = chai.expect;
10 //process.env['NODE_ENV'] = 'production';
14 describe('DB クラス', function() {
22 * @returns {promise}<保存したファイルのファイル名(uuid)をresolveする>
25 describe(constructor, function() {
34 it('should return hello when call sayHello', function() {
35 expect(db.sayHello()).to.equal('hello');
43 * 同一ディレクトリに同名のファイルが存在することを確かめる
44 * @param {string}fileName
45 * @param {string}parentDirectory
49 describe(existFile, function() {
62 it('should be rejected when does not exist same name file in a directory', function() {
63 return db.existFile('hogehoge.txt', '/').should.be.rejectedWith(Error, '"hogehoge.txt" does not exist in "/" directory.');
72 * 同一ディレクトリに同名のファイルが存在しないことを確かめる
73 * @param {string}fileName
74 * @param {string}parentDirectory
78 describe(notExistFile, function() {
91 it('should be rejected when exist the same name file in a directory', function() {
92 return db.notExistFile('hoge.txt', '/').should.be.rejectedWith(Error, '"hoge.txt" has already existed in "/" directory.');
98 var existDirectory = `
102 * @param {string} directory
103 * @returns {promise} ディレクトリが存在しなければresolve、すればreject
106 describe(existDirectory, function() {
115 it('should be rejected when does not exist directory', function() {
116 return db.existDirectory('hage').should.be.rejectedWith(Error, '"hage" directory doesn\'t exist.');
121 var notExistDirectory = `
124 * ディレクトリが存在しないことを確認する
125 * @param {string} directory
126 * @returns {promise} ディレクトリが存在すればresolve、存在しなければreject
129 describe(existDirectory, function() {
141 it('should be rejected when exists directory', function() {
142 return db.notExistDirectory('/').should.be.rejectedWith(Error,'"/" directory exists.');
152 * @returns {promise}<保存したファイルのファイル名(uuid)をresolveする>
155 describe(createFile, function() {
167 it('should be rejected when "parentDirectory" doesn\'t exist', function() {
168 return db.createFile('hoge.txt', 'hoge').should.be.rejectedWith(Error, '"hoge" directory doesn\'t exist.');
170 it('should be rejected when a file has already existed in a directory.', function() {
171 return db.createFile('hoge.txt', '/').should.be.rejectedWith(Error, '"hoge.txt" has already existed in "/" directory.');
182 * @param {string} fileName
183 * @param {string} parentDirectory
184 * @returns {promise} ファイル削除に成功すればresolve、失敗すればreject
188 describe(removeFile, function() {
199 it('should be resolved when removeFile() successed', function() {
200 return db.removeFile('hoge.txt', '/')
202 return db.existFile('hoge.txt', '/')
204 .should.be.rejectedWith(Error, '"hoge.txt" does not exist in "/" directory.');