Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update jasmine to 2.x #990

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions .github/workflows/editor-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ jobs:

- name: Run Tests
if: runner.os != 'Linux'
run: node script/run-tests.js spec
run: yarn test:editor

- name: Run Tests with xvfb-run (Linux)
if: runner.os == 'Linux'
run: xvfb-run --auto-servernum node script/run-tests.js spec
run: xvfb-run --auto-servernum yarn test:editor
1 change: 0 additions & 1 deletion .github/workflows/package-tests-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,3 @@ jobs:

- name: Run ${{ matrix.package }} Tests
run: Xvfb :1 & cd node_modules/${{ matrix.package }} && if test -d spec; then DISPLAY=:1 pulsar --test spec; fi
# run: node -e "require('./script/run-package-tests')(/${{ matrix.package }}/)"
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"engines": {
"node": ">=14"
},
"atomTestRunner": "runners/jasmine2-test-runner",
"license": "MIT",
"electronVersion": "12.2.3",
"resolutions": {
Expand Down Expand Up @@ -86,8 +87,8 @@
"image-view": "file:packages/image-view",
"incompatible-packages": "file:packages/incompatible-packages",
"jasmine-json": "~0.0",
"jasmine-reporters": "1.1.0",
"jasmine-tagged": "^1.1.4",
"jasmine": "2.5.3",
"key-path-helpers": "^0.4.0",
"keybinding-resolver": "file:./packages/keybinding-resolver",
"language-c": "file:packages/language-c",
Expand Down Expand Up @@ -293,7 +294,9 @@
"start": "electron --no-sandbox --enable-logging . -f",
"dist": "node script/electron-builder.js",
"js-docs": "jsdoc2md --files src --configure docs/.jsdoc.json > ./docs/Pulsar-API-Documentation.md",
"private-js-docs": "jsdoc2md --private --files src --configure docs/.jsdoc.json > ./docs/Source-Code-Documentation.md"
"private-js-docs": "jsdoc2md --private --files src --configure docs/.jsdoc.json > ./docs/Source-Code-Documentation.md",
"test:editor": "yarn test:only spec",
"test:only": "yarn start --test"
},
"devDependencies": {
"@electron/notarize": "^1.2.3",
Expand Down
1 change: 1 addition & 0 deletions packages/archive-view/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"engines": {
"atom": "*"
},
"atomTestRunner": "runners/jasmine2-test-runner",
"deserializers": {
"ArchiveEditor": "deserialize",
"ArchiveEditorView": "deserialize"
Expand Down
2 changes: 0 additions & 2 deletions packages/archive-view/spec/archive-editor-spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const {it, fit, ffit, fffit, beforeEach, afterEach, conditionPromise} = require('./async-spec-helpers') // eslint-disable-line no-unused-vars

const path = require('path')
const ArchiveEditor = require('../lib/archive-editor')
const ArchiveEditorView = require('../lib/archive-editor-view')
Expand Down
12 changes: 6 additions & 6 deletions packages/archive-view/spec/archive-editor-view-spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const {Disposable, File} = require('atom')
const getIconServices = require('../lib/get-icon-services')
const {it, fit, ffit, fffit, beforeEach, afterEach, conditionPromise} = require('./async-spec-helpers') // eslint-disable-line no-unused-vars
const {conditionPromise} = require('./async-spec-helpers') // eslint-disable-line no-unused-vars

async function condition (handler) {
if (jasmine.isSpy(window.setTimeout)) {
Expand All @@ -13,21 +13,21 @@ describe('ArchiveEditorView', () => {
let archiveEditorView, onDidChangeCallback, onDidRenameCallback, onDidDeleteCallback

beforeEach(async () => {
spyOn(File.prototype, 'onDidChange').andCallFake(function (callback) {
spyOn(File.prototype, 'onDidChange').and.callFake(function (callback) {
if (/\.tar$/.test(this.getPath())) {
onDidChangeCallback = callback
}
return new Disposable()
})

spyOn(File.prototype, 'onDidRename').andCallFake(function (callback) {
spyOn(File.prototype, 'onDidRename').and.callFake(function (callback) {
if (/\.tar$/.test(this.getPath())) {
onDidRenameCallback = callback
}
return new Disposable()
})

spyOn(File.prototype, 'onDidDelete').andCallFake(function (callback) {
spyOn(File.prototype, 'onDidDelete').and.callFake(function (callback) {
if (/\.tar$/.test(this.getPath())) {
onDidDeleteCallback = callback
}
Expand Down Expand Up @@ -150,9 +150,9 @@ describe('ArchiveEditorView', () => {

describe('when the file is renamed', () => {
it('refreshes the view and updates the title', async () => {
spyOn(File.prototype, 'getPath').andReturn('nested-renamed.tar')
spyOn(File.prototype, 'getPath').and.returnValue('nested-renamed.tar')
await condition(() => archiveEditorView.element.querySelectorAll('.entry').length > 0)
spyOn(archiveEditorView, 'refresh').andCallThrough()
spyOn(archiveEditorView, 'refresh').and.callThrough()
spyOn(archiveEditorView, 'getTitle')
onDidRenameCallback()
expect(archiveEditorView.refresh).toHaveBeenCalled()
Expand Down
82 changes: 1 addition & 81 deletions packages/archive-view/spec/async-spec-helpers.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,5 @@
/** @babel */

export function beforeEach (fn) {
global.beforeEach(function () {
const result = fn()
if (result instanceof Promise) {
waitsForPromise(() => result)
}
})
}

export function afterEach (fn) {
global.afterEach(function () {
const result = fn()
if (result instanceof Promise) {
waitsForPromise(() => result)
}
})
}

['it', 'fit', 'ffit', 'fffit'].forEach(function (name) {
module.exports[name] = function (description, fn) {
if (fn === undefined) {
global[name](description)
return
}

global[name](description, function () {
const result = fn()
if (result instanceof Promise) {
waitsForPromise(() => result)
}
})
}
})

export async function conditionPromise (condition, description = 'anonymous condition') {
const startTime = Date.now()

Expand All @@ -50,54 +16,8 @@ export async function conditionPromise (condition, description = 'anonymous cond
}
}

export function timeoutPromise (timeout) {
function timeoutPromise (timeout) {
return new Promise(function (resolve) {
global.setTimeout(resolve, timeout)
})
}

function waitsForPromise (fn) {
const promise = fn()
global.waitsFor('spec promise to resolve', function (done) {
promise.then(done, function (error) {
jasmine.getEnv().currentSpec.fail(error)
done()
})
})
}

export function emitterEventPromise (emitter, event, timeout = 15000) {
return new Promise((resolve, reject) => {
const timeoutHandle = setTimeout(() => {
reject(new Error(`Timed out waiting for '${event}' event`))
}, timeout)
emitter.once(event, () => {
clearTimeout(timeoutHandle)
resolve()
})
})
}

export function promisify (original) {
return function (...args) {
return new Promise((resolve, reject) => {
args.push((err, ...results) => {
if (err) {
reject(err)
} else {
resolve(...results)
}
})

return original(...args)
})
}
}

export function promisifySome (obj, fnNames) {
const result = {}
for (const fnName of fnNames) {
result[fnName] = promisify(obj[fnName])
}
return result
}
7 changes: 2 additions & 5 deletions script/electron-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,8 @@ let options = {

// Core Repo Test Inclusions
"spec/jasmine-test-runner.js",
"spec/spec-helper.js",
"spec/jasmine-junit-reporter.js",
"spec/spec-helper-functions.js",
"spec/atom-reporter.js",
"spec/jasmine-list-reporter.js",
"spec/helpers/**/*",
"spec/runners/**/*",

// --- Exclusions ---
// Core Repo Exclusions
Expand Down
20 changes: 0 additions & 20 deletions script/run-package-tests.js

This file was deleted.

76 changes: 0 additions & 76 deletions script/run-tests.js

This file was deleted.

Loading
Loading