OSDN Git Service

existDirectory(),notExistDirectory()の仕様変更、Filesテーブルのスキーマの変更
[eos/zephyr.git] / test / mocha / DB.test.js
index 3bfc150..cc33c8e 100644 (file)
                 .then(function() {
                     return db.test1();
                 })
+                .then(function() {
+                    return db.test2();
+                });
             });
 
-            /*
-               it('should be rejected when does not exist same name file in a directory', function() {
+            it('should be rejected when does not exist same name file in a directory', function() {
                return db.existFile('hogehoge.txt', '/').should.be.rejectedWith(Error, '"hogehoge.txt" does not exist in "/" directory.');
-               });
-               */
+            });
+            it('should be rejected when a directory does not exist', function() {
+               return db.existFile('hogehoge.txt', '/hoge').should.be.rejectedWith(Error, '"/hoge" directory doesn\'t exist.');
+            });
+            it('should be resolved when file exists in a directory', function() {
+               return expect(db.existFile('hogehoge.txt', '/one')).to.eventually.be.a('string');
+            });
+
         });
 
 
                 .then(function() {
                     return db.test1();
                 })
+                .then(function() {
+                    return db.test2();
+                });
             });
 
-
-            /*
-               it('should be rejected when exist the same name file in a directory', function() {
+            it('should be rejected when the same name file has already existed in directory(1)', function() {
                return db.notExistFile('hoge.txt', '/').should.be.rejectedWith(Error, '"hoge.txt" has already existed in "/" directory.');
-               });
-               */
-        });
-
+            });
+            it('should be rejected when the same name file has already existed in directory(2)', function() {
+               return db.notExistFile('hogehoge.txt', '/one').should.be.rejectedWith(Error, '"hogehoge.txt" has already existed in "/one" directory.');
+            });
+            it('should be resolved when the same name file does not exist in directory', function() {
+               return expect(db.notExistFile('hoge.txt', '/one')).to.eventually.equal();
+            });
 
+        });
 
         var existDirectory = `
         /**
                 })
             });
 
-            it('should be resolved when a directory exists.', function() {
-               return expect(db.existDirectory('/one/two')).to.eventually.equal('/one/two');
-            });
             it('should be rejected when does not exist directory', function() {
-               return db.existDirectory('/one/two/four').should.be.rejectedWith(Error, '"/one/two/four" directory doesn\'t exist.');
+                return db.existDirectory('/one/two/four').should.be.rejectedWith(Error, '"/one/two/four" directory doesn\'t exist.');
+            });
+            it('should be resolved when exists directory(1)', function() {
+                return expect(db.existDirectory('/')).to.eventually.equal('1f83f620-c1ed-11e5-9657-7942989daa00');
+            });
+            it('should be resolved when exists directory(2)', function() {
+                return expect(db.existDirectory('/one')).to.eventually.be.a('string');
+            });
+            it('should be resolved when exists directory(3)', function() {
+                return expect(db.existDirectory('/one/two')).to.eventually.be.a('string');
             });
-
-            /*
-               it('should be resolveed when exists directory(1)', function() {
-               return expect(db.existDirectory('/')).to.eventually.equal('/');
-               });
-               it('should be resolveed when exists directory(2)', function() {
-               return db.existDirectory('/one').should.be.rejectedWith(Error, '"hage" directory doesn\'t exist.');
-               });
-               it('should be resolveed when exists directory(3)', function() {
-               return db.existDirectory('/one/two').should.be.rejectedWith(Error, '"hage" directory doesn\'t exist.');
-               });
-               */
-
         });
 
 
                 .then(function() {
                     return db.test1();
                 })
+                .then(function() {
+                    return db.test2();
+                });
             });
 
-            /*
-               it('should be rejected when exists directory', function() {
+            it('should be rejected when exists directory(1)', function() {
                return db.notExistDirectory('/').should.be.rejectedWith(Error,'"/" directory exists.');
-               });
-               */
+            });
+            it('should be rejected when exists directory(2)', function() {
+               return db.notExistDirectory('/one').should.be.rejectedWith(Error,'"/one" directory exists.');
+            });
+            it('should be rejected when exists directory(3)', function() {
+               return db.notExistDirectory('/one/two').should.be.rejectedWith(Error,'"/one/two" directory exists.');
+            });
+
         });
 
         var createFile = `
                 .then(function() {
                     return db.test1();
                 })
+                .then(function() {
+                    return db.createFile('tarou.txt', '/');
+                });
             });
 
-            /*
-               it('should be rejected when "parentDirectory" doesn\'t exist', function() {
-               return db.createFile('hoge.txt', 'hoge').should.be.rejectedWith(Error, '"hoge" directory doesn\'t exist.');
-               });
-               it('should be rejected when a file has already existed in a directory.', function() {
+            it('should be rejected when "parentDirectory" doesn\'t exist', function() {
+               return db.createFile('hoge.txt', '/hoge').should.be.rejectedWith(Error, '"/hoge" directory doesn\'t exist.');
+            });
+            it('should be rejected when a file has already existed in a directory.', function() {
                return db.createFile('hoge.txt', '/').should.be.rejectedWith(Error, '"hoge.txt" has already existed in "/" directory.');
-               });
-               */
+            });
+            it('should be resolved when file creation successed.', function() {
+                return expect(db.existFile('tarou.txt', '/')).to.eventually.be.a('string');
+            });
         });
 
 
                     return db.test1();
                 });
             });
-            /*
-               it('should be resolved when removeFile() successed', function() {
+            it('should be resolved when removeFile() successed', function() {
                return db.removeFile('hoge.txt', '/')
                .then(function() {
                return db.existFile('hoge.txt', '/')
                })
                .should.be.rejectedWith(Error, '"hoge.txt" does not exist in "/" directory.');
-               });
-               */
+            });
         });
     });
 })();