Skip to content

Commit 7c02868

Browse files
committed
test: make tests running
1 parent d9d7164 commit 7c02868

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"test.format": "prettier . --check",
1111
"lint": "eslint . --fix",
1212
"test.lint": "eslint .",
13-
"test": "atom --test spec",
13+
"test": "npm run babel && atom --test spec",
1414
"clean": "shx rm -rf dist",
1515
"babel": "npm run clean && shx cp -r src dist && cross-env NODE_ENV=development cross-env BABEL_KEEP_MODULES=false babel dist --out-dir dist",
1616
"dev": "npm run clean && cross-env NODE_ENV=development cross-env BABEL_KEEP_MODULES=true rollup -c -w",
@@ -88,6 +88,7 @@
8888
"rxjs-compat": "6.3.3"
8989
},
9090
"devDependencies": {
91+
"@artemv/wait-until-promise": "^1.1.2",
9192
"@babel/cli": "7.13.16",
9293
"@babel/core": "7.14.0",
9394
"@types/atom": "1.40.10",
@@ -104,6 +105,7 @@
104105
"rollup": "^2.46.0",
105106
"rollup-plugin-atomic": "^2.3.1",
106107
"shx": "^0.3.3",
108+
"temp": "^0.9.4",
107109
"typescript": "^4.2.4"
108110
},
109111
"prettier": "prettier-config-atomic"

pnpm-lock.yaml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

__atom_tests__/CodeFormatManager-test.js renamed to spec/CodeFormatManager-spec.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
"use babel"
12
import {Range} from 'atom';
23
import {observeTextEditors} from '@atom-ide-community/nuclide-commons-atom/FileEventHandlers';
34
import {SAVE_TIMEOUT} from '../dist/CodeFormatManager';
45
import UniversalDisposable from '@atom-ide-community/nuclide-commons/UniversalDisposable';
56
import temp from 'temp';
67
import * as config from '../dist/config';
78
import CodeFormatManager from '../dist/CodeFormatManager';
8-
import waitsFor from '../../../../../jest/waits_for';
9+
import waitsFor from '@artemv/wait-until-promise';
910

1011
const sleep = n => new Promise(r => setTimeout(r, n));
1112

@@ -64,7 +65,7 @@ describe('CodeFormatManager', () => {
6465
});
6566

6667
it('formats an editor on type', async () => {
67-
jest.spyOn(config, 'getFormatOnType').mockReturnValue(true);
68+
spyOn(config, 'getFormatOnType').and.returnValue(true);
6869
const provider = {
6970
grammarScopes: ['text.plain.null-grammar'],
7071
priority: 1,
@@ -78,7 +79,7 @@ describe('CodeFormatManager', () => {
7879
]),
7980
keepCursorPosition: false,
8081
};
81-
const spy = jest.spyOn(provider, 'formatAtPosition');
82+
const spy = spyOn(provider, 'formatAtPosition');
8283
manager.addOnTypeProvider(provider);
8384

8485
textEditor.setText('a');
@@ -92,7 +93,7 @@ describe('CodeFormatManager', () => {
9293
});
9394

9495
it('formats an editor on save', async () => {
95-
jest.spyOn(config, 'getFormatOnSave').mockReturnValue(true);
96+
spyOn(config, 'getFormatOnSave').and.returnValue(true);
9697
manager.addOnSaveProvider({
9798
grammarScopes: ['text.plain.null-grammar'],
9899
priority: 1,
@@ -112,7 +113,7 @@ describe('CodeFormatManager', () => {
112113
});
113114

114115
it('should still save on timeout', async () => {
115-
jest.spyOn(config, 'getFormatOnSave').mockReturnValue(true);
116+
spyOn(config, 'getFormatOnSave').and.returnValue(true);
116117
manager.addRangeProvider({
117118
grammarScopes: ['text.plain.null-grammar'],
118119
priority: 1,
@@ -122,7 +123,7 @@ describe('CodeFormatManager', () => {
122123
},
123124
});
124125

125-
const spy = jest.spyOn(textEditor.getBuffer(), 'save');
126+
const spy = spyOn(textEditor.getBuffer(), 'save');
126127
textEditor.save();
127128

128129
// Wait until the buffer has been saved and verify it has been saved exactly

spec/runner.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"use babel"
2+
import { createRunner } from "atom-jasmine3-test-runner"
3+
4+
// https://github.com/UziTech/atom-jasmine3-test-runner#api
5+
export default createRunner({
6+
timeReporter: true,
7+
specHelper: true,
8+
})

0 commit comments

Comments
 (0)