Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
[removed] redundant Number conversion in watch
Browse files Browse the repository at this point in the history
  • Loading branch information
thealjey committed Dec 31, 2015
1 parent 6da6e97 commit 4299688
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/quicksearch.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/watch.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ <h1 class="page-title">Source: watch.js</h1>
* watch(join(__dirname, 'src'), 'js', someFunction);
*/
export function watch(dir: string, type: string, callback: () => void) {
const subscription = Number(Date.now()).toString(ALPHANUMERIC_BASE);
const subscription = Date.now().toString(ALPHANUMERIC_BASE);

client.capabilityCheck({}, capabilityErr => {
if (capabilityErr) {
Expand Down
2 changes: 1 addition & 1 deletion lib/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var client = new _fbWatchman.Client(),
* watch(join(__dirname, 'src'), 'js', someFunction);
*/
function watch(dir, type, callback) {
var subscription = Number(Date.now()).toString(ALPHANUMERIC_BASE);
var subscription = Date.now().toString(ALPHANUMERIC_BASE);

client.capabilityCheck({}, function (capabilityErr) {
if (capabilityErr) {
Expand Down
2 changes: 1 addition & 1 deletion src/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const client = new Client(),
* watch(join(__dirname, 'src'), 'js', someFunction);
*/
export function watch(dir: string, type: string, callback: () => void) {
const subscription = Number(Date.now()).toString(ALPHANUMERIC_BASE);
const subscription = Date.now().toString(ALPHANUMERIC_BASE);

client.capabilityCheck({}, capabilityErr => {
if (capabilityErr) {
Expand Down
9 changes: 4 additions & 5 deletions test/watch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,20 @@ class Client {
const ALPHANUMERIC_BASE = 36,
watch = proxyquire('../src/watch', {'fb-watchman': {Client}}).watch;

let callback;
let callback, toString;

describe('watch', () => {

beforeEach(() => {
callback = spy();
stub(Date, 'now');
stub(Number.prototype, 'toString').returns('qwerty');
toString = stub().returns('qwerty');
stub(Date, 'now').returns({toString});
stub(console, 'log');
stub(console, 'error');
});

afterEach(() => {
Date.now.restore();
Number.prototype.toString.restore();
console.log.restore();
console.error.restore();
});
Expand All @@ -48,7 +47,7 @@ describe('watch', () => {
});

it('calls number toString', () => {
expect(Number.prototype.toString).calledWith(ALPHANUMERIC_BASE);
expect(toString).calledWith(ALPHANUMERIC_BASE);
});

});
Expand Down

0 comments on commit 4299688

Please sign in to comment.