summaryrefslogtreecommitdiffstats
path: root/gin/test/file_unittests.js
blob: 8c25806e13994e2b48e53a2c3b0897d1030b1ae9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

define([
    "gin/test/expect",
    "file"
  ], function(expect, file) {

  function isString(x) {
    return toString.call(x) === '[object String]'
  }

  var rootDir = file.getSourceRootDirectory();
  expect(isString(rootDir)).toBeTruthy();

  var noArgsNull = file.getFilesInDirectory();
  expect(noArgsNull).toBeNull();

  var files = file.getFilesInDirectory(rootDir);
  expect(Array.isArray(files)).toBeTruthy();

  var nsdNull = file.getFilesInDirectory(rootDir + "/no_such_dir");
  expect(nsdNull).toBeNull();

  var owners = file.readFileToString(rootDir + "/OWNERS");
  expect(isString(owners)).toBeTruthy();
  expect(owners.length).toBeGreaterThan(0);

  noArgsNull = file.readFileToString();
  expect(noArgsNull).toBeNull();

  var nsfNull = file.readFileToString(rootDir + "/no_such_file");
  expect(nsfNull).toBeNull();

  this.result = "PASS";
});