This repository has been archived by the owner on Dec 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
185194b
commit 0c6f35f
Showing
16 changed files
with
334 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the LICENSE file in | ||
* the root directory of this source tree. | ||
* | ||
* @flow strict-local | ||
* @format | ||
*/ | ||
|
||
test('pass', () => { | ||
const atom = require('atom'); | ||
const electron = require('electron'); | ||
|
||
expect(atom).toBeDefined(); | ||
expect(electron).toBeDefined(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the LICENSE file in | ||
* the root directory of this source tree. | ||
* | ||
* @flow strict-local | ||
* @format | ||
*/ | ||
|
||
test('fake timers are not available yet', () => { | ||
expect(() => { | ||
jest.useFakeTimers(); | ||
}).toThrow('fakeTimers are not supproted in atom environment'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the LICENSE file in | ||
* the root directory of this source tree. | ||
* | ||
* @flow strict | ||
* @format | ||
*/ | ||
|
||
test('atom', () => { | ||
expect(1).toBe(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the LICENSE file in | ||
* the root directory of this source tree. | ||
* | ||
* @flow strict | ||
* @format | ||
*/ | ||
|
||
test('atom', () => { | ||
expect(2).toBe(2); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the LICENSE file in | ||
* the root directory of this source tree. | ||
* | ||
* @flow strict | ||
* @format | ||
*/ | ||
|
||
// eslint-disable-next-line nuclide-internal/no-commonjs | ||
module.exports = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the LICENSE file in | ||
* the root directory of this source tree. | ||
* | ||
* @flow strict | ||
* @format | ||
*/ | ||
|
||
const logger: log4js$Logger = { | ||
debug: jest.fn(), | ||
error: jest.fn(), | ||
fatal: jest.fn(), | ||
info: jest.fn(), | ||
isLevelEnabled: jest.fn(), | ||
// $FlowFixMe | ||
level: jest.fn(), | ||
log: jest.fn(), | ||
mark: jest.fn(), | ||
removeLevel: jest.fn(), | ||
setLevel: jest.fn(), | ||
trace: jest.fn(), | ||
warn: jest.fn(), | ||
}; | ||
|
||
export const getLogger = (name: string): log4js$Logger => logger; | ||
|
||
const log4js = { | ||
getLogger, | ||
// $FlowFixMe | ||
configure: jest.fn(), | ||
}; | ||
|
||
export default log4js; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the LICENSE file in | ||
* the root directory of this source tree. | ||
* | ||
* @flow | ||
* @format | ||
*/ | ||
|
||
export function trackTiming<T>( | ||
eventName: string, | ||
operation: () => T, | ||
values?: {[key: string]: any} = {}, | ||
): T { | ||
return operation(); | ||
} | ||
|
||
export const track: any = jest.fn(); | ||
|
||
export const startTracking = () => { | ||
const timingTracker: any = { | ||
onError: jest.fn(), | ||
onSuccess: jest.fn(), | ||
}; | ||
|
||
return timingTracker; | ||
}; | ||
|
||
export const trackImmediate: any = jest.fn(); | ||
|
||
export const setRawAnalyticsService: any = jest.fn(); | ||
|
||
export const trackTimingSampled: any = jest.fn((event, fn) => fn()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the LICENSE file in | ||
* the root directory of this source tree. | ||
* | ||
* @flow strict | ||
* @format | ||
*/ | ||
|
||
import waitsFor from '../waits_for'; | ||
|
||
it('waits', async () => { | ||
let condition = false; | ||
Promise.resolve().then(() => (condition = true)); | ||
await waitsFor(() => condition); | ||
}); | ||
|
||
it("can't wait anymore", async () => { | ||
await expect(waitsFor(() => false, undefined, 1)).rejects.toThrow( | ||
'but it never did', | ||
); | ||
}); | ||
|
||
it('gives a message', async () => { | ||
await expect(waitsFor(() => false, 'lol', 1)).rejects.toThrow('lol'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (c) 2015-present, Facebook, Inc. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the license found in the LICENSE file in | ||
# the root directory of this source tree. | ||
|
||
THIS_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | ||
FBSOURCE_ROOT=$(realpath "$THIS_DIR""/../../..") | ||
|
||
|
||
cd "$FBSOURCE_ROOT""/xplat/nuclide/modules/jest-atom-runner" || exit | ||
|
||
./node_modules/.bin/babel src --out-dir build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the LICENSE file in | ||
* the root directory of this source tree. | ||
* | ||
* @noflow | ||
*/ | ||
'use strict'; | ||
|
||
/* eslint | ||
comma-dangle: [1, always-multiline], | ||
prefer-object-spread/prefer-object-spread: 0, | ||
nuclide-internal/no-commonjs: 0, | ||
*/ | ||
|
||
const path = require('path'); | ||
|
||
module.exports = { | ||
displayName: 'atom', | ||
rootDir: path.resolve(__dirname, '../../..'), | ||
roots: ['<rootDir>/xplat/nuclide'], | ||
testMatch: ['**/__atom_tests__/**/*.js?(x)'], | ||
transform: { | ||
'\\.js$': '<rootDir>/xplat/nuclide/modules/nuclide-jest/jestTransformer.js', | ||
}, | ||
setupTestFrameworkScriptFile: '<rootDir>/xplat/nuclide/jest/setupTestFrameworkScriptFile.atom.js', | ||
testPathIgnorePatterns: ['/node_modules/'], | ||
runner: path.resolve(__dirname, '../modules/jest-atom-runner/build/index.js'), | ||
moduleNameMapper: { | ||
oniguruma: path.resolve(__dirname, './__mocks__/emptyObject.js'), | ||
}, | ||
testEnvironment: | ||
'<rootDir>/xplat/nuclide/modules/jest-atom-runner/build/environment.js', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the LICENSE file in | ||
* the root directory of this source tree. | ||
* | ||
* @noflow | ||
*/ | ||
'use strict'; | ||
|
||
/* eslint | ||
comma-dangle: [1, always-multiline], | ||
prefer-object-spread/prefer-object-spread: 0, | ||
nuclide-internal/no-commonjs: 0, | ||
*/ | ||
|
||
const path = require('path'); | ||
|
||
module.exports = { | ||
displayName: 'node', | ||
rootDir: path.resolve(__dirname, '../../../'), | ||
roots: ['<rootDir>/xplat/nuclide'], | ||
testMatch: ['**/__tests__/**/*.js?(x)'], | ||
transform: { | ||
'\\.js$': '<rootDir>/xplat/nuclide/modules/nuclide-jest/jestTransformer.js', | ||
}, | ||
setupTestFrameworkScriptFile: '<rootDir>/xplat/nuclide/jest/setupTestFrameworkScriptFile.node.js', | ||
setupFiles: ['<rootDir>/xplat/nuclide/jest/setup.js'], | ||
testPathIgnorePatterns: ['/node_modules/'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the LICENSE file in | ||
* the root directory of this source tree. | ||
* | ||
* @flow strict | ||
* @format | ||
*/ | ||
|
||
jest.mock('nuclide-commons/analytics'); | ||
jest.mock('log4js'); | ||
|
||
global.NUCLIDE_DO_NOT_LOG = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the LICENSE file in | ||
* the root directory of this source tree. | ||
* | ||
* @flow strict-local | ||
* @format | ||
*/ | ||
|
||
beforeEach(async () => { | ||
await global.atom.reset(); | ||
}); | ||
|
||
// Disable prompt to download react devtools in atom tests | ||
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = {isDisabled: true}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the LICENSE file in | ||
* the root directory of this source tree. | ||
* | ||
* @flow strict-local | ||
* @format | ||
*/ | ||
|
||
jest.setTimeout(10000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the LICENSE file in | ||
* the root directory of this source tree. | ||
* | ||
* @flow strict | ||
* @format | ||
*/ | ||
|
||
/* | ||
* Async implementation of Jasmine's waitsFor() | ||
*/ | ||
export default (async function waitsFor( | ||
fn: () => boolean, | ||
message?: string, | ||
timeout: number = 4500, | ||
) { | ||
const error = new Error( | ||
message != null | ||
? message | ||
: 'Expected the function to start returning "true" but it never did', | ||
); | ||
const startTime = Date.now(); | ||
while (!Boolean(fn())) { | ||
if (Date.now() - startTime > timeout) { | ||
throw error; | ||
} | ||
// eslint-disable-next-line no-await-in-loop | ||
await new Promise(resolve => setTimeout(resolve, 50)); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters