Skip to content

Commit

Permalink
Merge pull request #29 from jy95/prettier
Browse files Browse the repository at this point in the history
Prettier
  • Loading branch information
jy95 authored Apr 11, 2018
2 parents 08c7029 + 90bd75c commit be816e6
Show file tree
Hide file tree
Showing 14 changed files with 3,537 additions and 2,994 deletions.
136 changes: 75 additions & 61 deletions __mocks__/filehound.js
Original file line number Diff line number Diff line change
@@ -1,77 +1,91 @@
'use strict';
"use strict";

// need to manually mock these function as there is no solution : https://github.com/facebook/jest/issues/5589
// here ; a short truncated copy of babel stuff of this class
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
if (!self) {
throw new ReferenceError(
"this hasn't been initialised - super() hasn't been called"
);
}
return call && (typeof call === "object" || typeof call === "function")
? call
: self;
}

var _createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}

return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();

// truncated version of this stuff
var FileHound = function () {
var FileHound = (function() {
// temp files
let result;

// temp files
let result;

function FileHound() {
var _this = _possibleConstructorReturn(this, (FileHound.__proto__ || Object.getPrototypeOf(FileHound)).call(this));
return _this;
}
function FileHound() {
var _this = _possibleConstructorReturn(
this,
(FileHound.__proto__ || Object.getPrototypeOf(FileHound)).call(this)
);
return _this;
}

_createClass(FileHound, [
{
key: 'paths',
value: function paths() {
return this;
}
},
{
key: 'ext',
value: function ext() {
return this;
}
},
{
key: 'find',
value: function find() {
if (result !== undefined) {
return Promise.resolve(result);
}
// if nothing provided , throw error
return Promise.reject("VAUDOU");
}
}], [{
key: 'create',
_createClass(
FileHound,
[
{
key: "paths",
value: function paths() {
return this;
}
},
{
key: "ext",
value: function ext() {
return this;
}
},
{
key: "find",
value: function find() {
if (result !== undefined) {
return Promise.resolve(result);
}
// if nothing provided , throw error
return Promise.reject("VAUDOU");
}
}
],
[
{
key: "create",
value: function create() {
return new FileHound();
return new FileHound();
}
}, {
key: '__setResult',
value: function (ExpectedResult) {
result = ExpectedResult;
},
{
key: "__setResult",
value: function(ExpectedResult) {
result = ExpectedResult;
}
}]);
}
]
);

return FileHound;
}();
module.exports = FileHound;
return FileHound;
})();
module.exports = FileHound;
16 changes: 8 additions & 8 deletions __mocks__/fs.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
'use strict';
const fs = jest.genMockFromModule('fs');
"use strict";
const fs = jest.genMockFromModule("fs");

// temp files
let mockPaths = [];

function access(path, mode, callback) {
if (!mockPaths.includes(path)) {
callback(new Error("VAUDOU"));
}
callback();
if (!mockPaths.includes(path)) {
callback(new Error("VAUDOU"));
}
callback();
}

function __setMockPaths(pathArray) {
mockPaths = pathArray;
mockPaths = pathArray;
}

fs.access = access;
fs.__setMockPaths = __setMockPaths;

module.exports = fs;
module.exports = fs;
9 changes: 7 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ module.exports = {
"js"
],
"transform": {
"^.+\\.tsx?$": "ts-jest"
"^(?!.*\\.d\\.ts$).*\\.tsx?$": "ts-jest"
},
"testMatch": [
"<rootDir>/__tests__/**/*.(ts|tsx|js)"
],
"testPathIgnorePatterns": ["<rootDir>/node_modules/", "<rootDir>/__tests__/__helpers__/"],
"collectCoverage": true
"collectCoverage": true,
"globals": {
"ts-jest": {
"tsConfigFile": "tsconfig.jest.json"
}
}
};
Loading

0 comments on commit be816e6

Please sign in to comment.