mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-11 19:17:09 +03:00
Merge branch 'master' into bundle-time
This commit is contained in:
commit
c88bc26f40
43
.cirrus.yml
43
.cirrus.yml
@ -10,6 +10,7 @@ linux_task:
|
||||
- apt-get update
|
||||
- export DEBIAN_FRONTEND="noninteractive"
|
||||
- apt-get install -y
|
||||
ffmpeg
|
||||
rpm
|
||||
build-essential
|
||||
git
|
||||
@ -27,7 +28,7 @@ linux_task:
|
||||
- git submodule update
|
||||
- sed -i -e "s/[0-9]*-dev/`date -u +%Y%m%d%H`/g" package.json
|
||||
install_script:
|
||||
- yarn install || yarn install
|
||||
- yarn install --ignore-engines || yarn install --ignore-engines
|
||||
build_script:
|
||||
- yarn build
|
||||
- yarn run build:apm
|
||||
@ -36,7 +37,11 @@ linux_task:
|
||||
binary_artifacts:
|
||||
path: ./binaries/*
|
||||
test_script:
|
||||
- Xvfb :99 & DISPLAY=:99 PLAYWRIGHT_JUNIT_OUTPUT_NAME=report.xml npx playwright test --reporter=junit,list
|
||||
- rm -R node_modules/electron; yarn install --check-files
|
||||
- ./binaries/*AppImage --appimage-extract
|
||||
- export BINARY_NAME='squashfs-root/pulsar'
|
||||
- mkdir -p ./tests/videos
|
||||
- Xvfb -screen 0 1024x768x24+32 :99 & nohup ffmpeg -video_size 1024x768 -f x11grab -i :99.0 ./tests/videos/out.mpg & DISPLAY=:99 PLAYWRIGHT_JUNIT_OUTPUT_NAME=report.xml npx playwright test --reporter=junit,list
|
||||
always:
|
||||
videos_artifacts:
|
||||
path: ./tests/videos/**
|
||||
@ -81,17 +86,19 @@ arm_linux_task:
|
||||
- git submodule update
|
||||
- sed -i -e "s/[0-9]*-dev/`date -u +%Y%m%d%H`/g" package.json
|
||||
install_script:
|
||||
- yarn install || yarn install
|
||||
- yarn install --ignore-engines || yarn install --ignore-engines
|
||||
build_script:
|
||||
- yarn build
|
||||
- yarn run build:apm
|
||||
- rm -Rf node-modules/electron && yarn install --check-files
|
||||
build_binary_script:
|
||||
- source /etc/profile.d/rvm.sh
|
||||
- yarn dist || yarn dist
|
||||
binary_artifacts:
|
||||
path: ./binaries/*
|
||||
test_script:
|
||||
- rm -R node_modules/electron; yarn install --check-files
|
||||
- ./binaries/*AppImage --appimage-extract
|
||||
- export BINARY_NAME='squashfs-root/pulsar'
|
||||
- Xvfb :99 & DISPLAY=:99 PLAYWRIGHT_JUNIT_OUTPUT_NAME=report.xml npx playwright test --reporter=junit,list
|
||||
always:
|
||||
videos_artifacts:
|
||||
@ -121,7 +128,7 @@ silicon_mac_task:
|
||||
- sed -i -e "s/[0-9]*-dev/`date -u +%Y%m%d%H`/g" package.json
|
||||
install_script:
|
||||
- export PATH="/opt/homebrew/bin:/opt/homebrew/opt/node@16/bin:$PATH"
|
||||
- yarn install || yarn install
|
||||
- yarn install --ignore-engines || yarn install --ignore-engines
|
||||
build_script:
|
||||
- export PATH="/opt/homebrew/bin:/opt/homebrew/opt/node@16/bin:$PATH"
|
||||
- yarn build
|
||||
@ -133,6 +140,9 @@ silicon_mac_task:
|
||||
path: ./binaries/*
|
||||
test_script:
|
||||
- export PATH="/opt/homebrew/bin:/opt/homebrew/opt/node@16/bin:$PATH"
|
||||
- rm -R node_modules/electron; yarn install --check-files
|
||||
- hdiutil mount binaries/Pulsar*dmg
|
||||
- export BINARY_NAME=`ls /Volumes/Pulsar*/Pulsar.app/Contents/MacOS/Pulsar`
|
||||
- PLAYWRIGHT_JUNIT_OUTPUT_NAME=report.xml npx playwright test --reporter=junit,list
|
||||
always:
|
||||
videos_artifacts:
|
||||
@ -166,7 +176,7 @@ intel_mac_task:
|
||||
- sed -i -e "s/[0-9]*-dev/`date -u +%Y%m%d%H`/g" package.json
|
||||
install_script:
|
||||
- export PATH="/usr/local/opt/node@16/bin:/usr/local/bin:$PATH"
|
||||
- arch -x86_64 npx yarn install || arch -x86_64 npx yarn install
|
||||
- arch -x86_64 npx yarn install --ignore-engines || arch -x86_64 npx yarn install --ignore-engines
|
||||
build_script:
|
||||
- export PATH="/usr/local/opt/node@16/bin:/usr/local/bin:$PATH"
|
||||
- arch -x86_64 npx yarn build
|
||||
@ -178,6 +188,9 @@ intel_mac_task:
|
||||
path: ./binaries/*
|
||||
test_script:
|
||||
- export PATH="/usr/local/opt/node@16/bin:/usr/local/bin:$PATH"
|
||||
- rm -R node_modules/electron; yarn install --check-files
|
||||
- hdiutil mount binaries/Pulsar*dmg
|
||||
- export BINARY_NAME=`ls /Volumes/Pulsar*/Pulsar.app/Contents/MacOS/Pulsar`
|
||||
- PLAYWRIGHT_JUNIT_OUTPUT_NAME=report.xml arch -x86_64 npx playwright test --reporter=junit,list
|
||||
always:
|
||||
videos_artifacts:
|
||||
@ -189,20 +202,23 @@ intel_mac_task:
|
||||
|
||||
windows_task:
|
||||
alias: windows
|
||||
timeout_in: 90m
|
||||
windows_container:
|
||||
image: cirrusci/windowsservercore:visualstudio2022-2022.06.23
|
||||
env:
|
||||
CIRRUS_SHELL: bash
|
||||
PATH: C:\Python310\Scripts\;C:\Python310\;%PATH%;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Users\User\AppData\Local\Microsoft\WindowsApps;C:\Users\User\AppData\Roaming\npm;C:\Program Files\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin\
|
||||
prepare_script:
|
||||
- choco install nodejs --version=14.15.0 -y
|
||||
- choco install nodejs --version=16.16.0 -y
|
||||
- choco install python --version=3.10.3 -y
|
||||
- choco install git visualstudio2019-workload-vctools -y
|
||||
- git submodule init
|
||||
- git submodule update
|
||||
- npm config set python 'C:\Python310\python.exe'
|
||||
install_script:
|
||||
- npx yarn install --ignore-engines || sleep 1 && npx yarn install --ignore-engines || echo "There is a reason for so many tries"
|
||||
- npx yarn install --ignore-engines
|
||||
|| rm -R node_modules && npx yarn install --ignore-engines
|
||||
|| rm -R node_modules && npx yarn install --ignore-engines
|
||||
build_script:
|
||||
- npx yarn build:apm
|
||||
- npx yarn build || npx yarn build || npx yarn build
|
||||
@ -211,3 +227,14 @@ windows_task:
|
||||
- npx yarn dist || npx yarn dist || npx yarn dist
|
||||
binary_artifacts:
|
||||
path: .\binaries\*
|
||||
test_script:
|
||||
- mkdir extracted; tar -xf binaries/*zip -C ./extracted/
|
||||
- export BINARY_NAME=./extracted/Pulsar.exe
|
||||
- PLAYWRIGHT_JUNIT_OUTPUT_NAME=report.xml npx playwright test --reporter=junit,list || echo "Yeah, tests failed, Windows is like this"
|
||||
always:
|
||||
videos_artifacts:
|
||||
path: ./tests/videos/**
|
||||
junit_artifacts:
|
||||
path: report.xml
|
||||
type: text/xml
|
||||
format: junit
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- The settings-view package now lists a package’s snippets more accurately
|
||||
- Fixed some issues with some packages with WebComponents v0 (tablr package
|
||||
should work now) by internalizing and patching document-register-element
|
||||
- Migrated away from `node-oniguruma` in favor of `vscode-oniguruma` (WASM
|
||||
|
@ -14,6 +14,11 @@ async function openAtom(profilePath, videoName) {
|
||||
env: env,
|
||||
timeout: 50000
|
||||
}
|
||||
if(env.BINARY_NAME) {
|
||||
config.executablePath = env.BINARY_NAME
|
||||
config.args = ["--no-sandbox"]
|
||||
}
|
||||
|
||||
if(process.env.CI) {
|
||||
config.recordVideo = {
|
||||
dir: path.join('tests', 'videos', videoName)
|
||||
|
@ -51,8 +51,12 @@ export default class PackageSnippetsView {
|
||||
<input id='toggleSnippets' className='input-checkbox' type='checkbox' ref='snippetToggle' />
|
||||
<div className='setting-title'>Enable</div>
|
||||
</label>
|
||||
<div className='setting-description'>
|
||||
{'Disable this if you want to prevent this package’s snippets from appearing as suggestions or if you want to customize them in your snippets file.'}
|
||||
<div className='setting-description' ref='snippetSettingDescription'>
|
||||
<p>Disable this if you want to prevent this package’s snippets from appearing as suggestions or if you want to customize them in your snippets file.</p>
|
||||
|
||||
<p>To <strong>disable</strong> most snippets and <strong>enable</strong> just a few, use the <kbd>Copy</kbd> button on any snippet you want to enable, then paste the result into your own snippets file.</p>
|
||||
|
||||
<p>To <strong>enable</strong> most snippets and <strong>disable</strong> just a few, use the <kbd>Copy</kbd> button on any snippet you want to disable, paste the result into your own snippets file, and change the body to <code>null</code>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -60,6 +64,7 @@ export default class PackageSnippetsView {
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Trigger</th>
|
||||
<th ref="headingCommand">Command</th>
|
||||
<th>Name</th>
|
||||
<th>Scope</th>
|
||||
<th>Body</th>
|
||||
@ -73,13 +78,12 @@ export default class PackageSnippetsView {
|
||||
|
||||
getSnippetProperties () {
|
||||
const packageProperties = {}
|
||||
for (const {name, properties, selectorString} of this.snippetsProvider.getSnippets()) {
|
||||
for (const {name, properties} of this.snippetsProvider.getSnippets()) {
|
||||
if (name && name.indexOf && name.indexOf(this.packagePath) === 0) {
|
||||
const object = properties.snippets != null ? properties.snippets : {}
|
||||
for (let key in object) {
|
||||
const snippet = object[key]
|
||||
if (snippet != null) {
|
||||
snippet.selectorString = selectorString
|
||||
if (packageProperties[key] == null) {
|
||||
packageProperties[key] = snippet
|
||||
}
|
||||
@ -116,13 +120,15 @@ export default class PackageSnippetsView {
|
||||
this.getSnippets((snippets) => {
|
||||
this.refs.snippets.innerHTML = ''
|
||||
|
||||
let anyWithCommand = snippets.some(s => ('command' in s))
|
||||
|
||||
if (snippetsDisabled) {
|
||||
this.refs.snippets.classList.add('text-subtle')
|
||||
} else {
|
||||
this.refs.snippets.classList.remove('text-subtle')
|
||||
}
|
||||
|
||||
for (let {body, bodyText, name, prefix, selectorString} of snippets) {
|
||||
for (let {body, bodyText, command, name, packageName, prefix, selector} of snippets) {
|
||||
if (name == null) {
|
||||
name = ''
|
||||
}
|
||||
@ -135,8 +141,13 @@ export default class PackageSnippetsView {
|
||||
body = bodyText || ''
|
||||
}
|
||||
|
||||
if (selectorString == null) {
|
||||
selectorString = ''
|
||||
if (selector == null) {
|
||||
selector = ''
|
||||
}
|
||||
|
||||
let commandName = ''
|
||||
if (packageName && command) {
|
||||
commandName = `${packageName}:${command}`
|
||||
}
|
||||
|
||||
const row = document.createElement('tr')
|
||||
@ -146,13 +157,18 @@ export default class PackageSnippetsView {
|
||||
prefixTd.textContent = prefix
|
||||
row.appendChild(prefixTd)
|
||||
|
||||
const commandTd = document.createElement('td')
|
||||
commandTd.textContent = commandName
|
||||
row.appendChild(commandTd)
|
||||
commandTd.style.display = anyWithCommand ? '' : 'none'
|
||||
|
||||
const nameTd = document.createElement('td')
|
||||
nameTd.textContent = name
|
||||
row.appendChild(nameTd)
|
||||
|
||||
const scopeTd = document.createElement('td')
|
||||
scopeTd.classList.add('snippet-scope-name')
|
||||
scopeTd.textContent = selectorString
|
||||
scopeTd.textContent = selector
|
||||
row.appendChild(scopeTd)
|
||||
|
||||
const bodyTd = document.createElement('td')
|
||||
@ -160,7 +176,7 @@ export default class PackageSnippetsView {
|
||||
row.appendChild(bodyTd)
|
||||
|
||||
this.refs.snippets.appendChild(row)
|
||||
this.createButtonsForSnippetRow(bodyTd, {body, prefix, scope: selectorString, name})
|
||||
this.createButtonsForSnippetRow(bodyTd, {body, prefix, scope: selector, name, command})
|
||||
}
|
||||
|
||||
if (this.refs.snippets.children.length > 0) {
|
||||
@ -168,10 +184,14 @@ export default class PackageSnippetsView {
|
||||
} else {
|
||||
this.element.style.display = 'none'
|
||||
}
|
||||
|
||||
// The “Command” column should only be shown if at least one snippet is
|
||||
// mapped to a command name.
|
||||
this.refs.headingCommand.style.display = anyWithCommand ? '' : 'none'
|
||||
})
|
||||
}
|
||||
|
||||
createButtonsForSnippetRow (td, {scope, body, name, prefix}) {
|
||||
createButtonsForSnippetRow (td, {scope, body, name, prefix, command}) {
|
||||
let buttonContainer = document.createElement('div')
|
||||
buttonContainer.classList.add('btn-group', 'btn-group-xs')
|
||||
|
||||
@ -198,7 +218,7 @@ export default class PackageSnippetsView {
|
||||
|
||||
copyButton.addEventListener('click', (event) => {
|
||||
event.preventDefault()
|
||||
return this.writeSnippetToClipboard({scope, body, name, prefix})
|
||||
return this.writeSnippetToClipboard({scope, body, name, prefix, command})
|
||||
})
|
||||
|
||||
buttonContainer.appendChild(viewButton)
|
||||
@ -207,24 +227,39 @@ export default class PackageSnippetsView {
|
||||
td.appendChild(buttonContainer)
|
||||
}
|
||||
|
||||
writeSnippetToClipboard ({scope, body, name, prefix}) {
|
||||
writeSnippetToClipboard ({scope, body, name, prefix, command}) {
|
||||
let content
|
||||
const extension = path.extname(this.snippetsProvider.getUserSnippetsPath())
|
||||
body = body.replace(/\n/g, '\\n').replace(/\t/g, '\\t')
|
||||
// Either `prefix` or `command` will be present, or else both. Only copy
|
||||
// the values that are present.
|
||||
let triggers = []
|
||||
if (extension === '.cson') {
|
||||
if (prefix) {
|
||||
triggers.push(` 'prefix': '${prefix}'`)
|
||||
}
|
||||
if (command) {
|
||||
triggers.push(` 'command': '${command}'`)
|
||||
}
|
||||
body = body.replace(/'/g, `\\'`)
|
||||
content = `
|
||||
'${scope}':
|
||||
'${name}':
|
||||
'prefix': '${prefix}'
|
||||
${triggers.join('\n')}
|
||||
'body': '${body}'
|
||||
`
|
||||
} else {
|
||||
if (prefix) {
|
||||
triggers.push(` "prefix": "${prefix}"`)
|
||||
}
|
||||
if (command) {
|
||||
triggers.push(` "command": "${command}"`)
|
||||
}
|
||||
body = body.replace(/"/g, `\\"`)
|
||||
content = `
|
||||
"${scope}": {
|
||||
"${name}": {
|
||||
"prefix": "${prefix}",
|
||||
${triggers.join(',\n')}
|
||||
"body": "${body}"
|
||||
}
|
||||
}
|
||||
|
14
packages/settings-view/spec/.eslintrc.js
Normal file
14
packages/settings-view/spec/.eslintrc.js
Normal file
@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
es2021: true,
|
||||
jasmine: true,
|
||||
node: true
|
||||
},
|
||||
globals: {
|
||||
waitsForPromise: true
|
||||
},
|
||||
rules: {
|
||||
"node/no-missing-require": "off",
|
||||
"semi": ["error", "always"]
|
||||
}
|
||||
};
|
@ -2,6 +2,7 @@
|
||||
".source.b": {
|
||||
"BAR": {
|
||||
"prefix": "b",
|
||||
"command": "sample-command",
|
||||
"body": "bar?\nline two"
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
".source.a": {
|
||||
".source.a, .source.aa": {
|
||||
"FOO": {
|
||||
"prefix": "f",
|
||||
"body": "foo!"
|
||||
|
@ -1,338 +0,0 @@
|
||||
path = require 'path'
|
||||
PackageDetailView = require '../lib/package-detail-view'
|
||||
PackageManager = require '../lib/package-manager'
|
||||
SettingsView = require '../lib/settings-view'
|
||||
PackageKeymapView = require '../lib/package-keymap-view'
|
||||
PackageSnippetsView = require '../lib/package-snippets-view'
|
||||
_ = require 'underscore-plus'
|
||||
SnippetsProvider =
|
||||
getSnippets: -> atom.config.scopedSettingsStore.propertySets
|
||||
|
||||
describe "InstalledPackageView", ->
|
||||
beforeEach ->
|
||||
spyOn(PackageManager.prototype, 'loadCompatiblePackageVersion').andCallFake ->
|
||||
|
||||
it "displays the grammars registered by the package", ->
|
||||
settingsPanels = null
|
||||
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'language-test'))
|
||||
|
||||
runs ->
|
||||
pack = atom.packages.getActivePackage('language-test')
|
||||
view = new PackageDetailView(pack, new SettingsView(), new PackageManager(), SnippetsProvider)
|
||||
settingsPanels = view.element.querySelectorAll('.package-grammars .settings-panel')
|
||||
|
||||
waitsFor ->
|
||||
children = Array.from(settingsPanels).map((s) -> s.children.length)
|
||||
childrenCount = children.reduce(((a, b) -> a + b), 0)
|
||||
childrenCount is 2
|
||||
|
||||
expect(settingsPanels[0].querySelector('.grammar-scope').textContent).toBe 'Scope: source.a'
|
||||
expect(settingsPanels[0].querySelector('.grammar-filetypes').textContent).toBe 'File Types: .a, .aa, a'
|
||||
|
||||
expect(settingsPanels[1].querySelector('.grammar-scope').textContent).toBe 'Scope: source.b'
|
||||
expect(settingsPanels[1].querySelector('.grammar-filetypes').textContent).toBe 'File Types: '
|
||||
|
||||
expect(settingsPanels[2]).toBeUndefined()
|
||||
|
||||
it "displays the snippets registered by the package", ->
|
||||
snippetsTable = null
|
||||
snippetsModule = null
|
||||
|
||||
# Relies on behavior not present in the snippets package before 1.33.
|
||||
# TODO: These tests should always run once 1.33 is released.
|
||||
shouldRunScopeTest = parseFloat(atom.getVersion()) >= 1.33
|
||||
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'language-test'))
|
||||
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage('snippets').then (p) ->
|
||||
snippetsModule = p.mainModule
|
||||
return unless snippetsModule.provideSnippets().getUnparsedSnippets?
|
||||
|
||||
SnippetsProvider =
|
||||
getSnippets: -> snippetsModule.provideSnippets().getUnparsedSnippets()
|
||||
|
||||
waitsFor 'snippets to load', -> snippetsModule.provideSnippets().bundledSnippetsLoaded()
|
||||
|
||||
runs ->
|
||||
pack = atom.packages.getActivePackage('language-test')
|
||||
view = new PackageDetailView(pack, new SettingsView(), new PackageManager(), SnippetsProvider)
|
||||
snippetsTable = view.element.querySelector('.package-snippets-table tbody')
|
||||
|
||||
waitsFor 'snippets table children to contain 2 items', ->
|
||||
snippetsTable.children.length >= 2
|
||||
|
||||
runs ->
|
||||
expect(snippetsTable.querySelector('tr:nth-child(1) td:nth-child(1)').textContent).toBe 'b'
|
||||
expect(snippetsTable.querySelector('tr:nth-child(1) td:nth-child(2)').textContent).toBe 'BAR'
|
||||
expect(snippetsTable.querySelector('tr:nth-child(1) td.snippet-scope-name').textContent).toBe '.b.source' if shouldRunScopeTest
|
||||
|
||||
expect(snippetsTable.querySelector('tr:nth-child(2) td:nth-child(1)').textContent).toBe 'f'
|
||||
expect(snippetsTable.querySelector('tr:nth-child(2) td:nth-child(2)').textContent).toBe 'FOO'
|
||||
expect(snippetsTable.querySelector('tr:nth-child(2) td.snippet-scope-name').textContent).toBe '.a.source' if shouldRunScopeTest
|
||||
|
||||
describe "when a snippet body is viewed", ->
|
||||
it "shows a tooltip", ->
|
||||
tooltipCalls = []
|
||||
view = null
|
||||
snippetsTable = null
|
||||
snippetsModule = null
|
||||
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'language-test'))
|
||||
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage('snippets').then (p) ->
|
||||
snippetsModule = p.mainModule
|
||||
return unless snippetsModule.provideSnippets().getUnparsedSnippets?
|
||||
|
||||
SnippetsProvider =
|
||||
getSnippets: -> snippetsModule.provideSnippets().getUnparsedSnippets()
|
||||
|
||||
waitsFor 'snippets to load', -> snippetsModule.provideSnippets().bundledSnippetsLoaded()
|
||||
|
||||
runs ->
|
||||
pack = atom.packages.getActivePackage('language-test')
|
||||
view = new PackageDetailView(pack, new SettingsView(), new PackageManager(), SnippetsProvider)
|
||||
snippetsTable = view.element.querySelector('.package-snippets-table tbody')
|
||||
|
||||
waitsFor 'snippets table children to contain 2 items', ->
|
||||
snippetsTable.children.length >= 2
|
||||
|
||||
runs ->
|
||||
expect(view.element.ownerDocument.querySelector('.snippet-body-tooltip')).not.toExist()
|
||||
|
||||
view.element.querySelector('.package-snippets-table tbody tr:nth-child(1) td.snippet-body .snippet-view-btn').click()
|
||||
expect(view.element.ownerDocument.querySelector('.snippet-body-tooltip')).toExist()
|
||||
|
||||
|
||||
# Relies on behavior not present in the snippets package before 1.33.
|
||||
# TODO: These tests should always run once 1.33 is released.
|
||||
if parseFloat(atom.getVersion()) >= 1.33
|
||||
describe "when a snippet is copied", ->
|
||||
[pack, card] = []
|
||||
snippetsTable = null
|
||||
snippetsModule = null
|
||||
|
||||
beforeEach ->
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'language-test'))
|
||||
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage('snippets').then (p) ->
|
||||
snippetsModule = p.mainModule
|
||||
return unless snippetsModule.provideSnippets().getUnparsedSnippets?
|
||||
|
||||
SnippetsProvider =
|
||||
getSnippets: -> snippetsModule.provideSnippets().getUnparsedSnippets()
|
||||
getUserSnippetsPath: snippetsModule.getUserSnippetsPath()
|
||||
|
||||
waitsFor 'snippets to load', -> snippetsModule.provideSnippets().bundledSnippetsLoaded()
|
||||
|
||||
runs ->
|
||||
pack = atom.packages.getActivePackage('language-test')
|
||||
card = new PackageSnippetsView(pack, SnippetsProvider)
|
||||
snippetsTable = card.element.querySelector('.package-snippets-table tbody')
|
||||
|
||||
waitsFor 'snippets table children to contain 2 items', ->
|
||||
snippetsTable.children.length >= 2
|
||||
|
||||
describe "when the snippets file ends in .cson", ->
|
||||
it "writes a CSON snippet to the clipboard", ->
|
||||
spyOn(SnippetsProvider, 'getUserSnippetsPath').andReturn('snippets.cson')
|
||||
card.element.querySelector('.package-snippets-table tbody tr:nth-child(1) td.snippet-body .snippet-copy-btn').click()
|
||||
expect(atom.clipboard.read()).toBe """
|
||||
\n'.b.source':
|
||||
'BAR':
|
||||
'prefix': 'b'
|
||||
'body': 'bar?\\nline two'\n
|
||||
"""
|
||||
|
||||
describe "when the snippets file ends in .json", ->
|
||||
it "writes a JSON snippet to the clipboard", ->
|
||||
spyOn(SnippetsProvider, 'getUserSnippetsPath').andReturn('snippets.json')
|
||||
card.element.querySelector('.package-snippets-table tbody tr:nth-child(1) td.snippet-body .btn:nth-child(2)').click()
|
||||
expect(atom.clipboard.read()).toBe """
|
||||
\n ".b.source": {
|
||||
"BAR": {
|
||||
"prefix": "b",
|
||||
"body": "bar?\\nline two"
|
||||
}
|
||||
}\n
|
||||
"""
|
||||
|
||||
describe "when the snippets toggle is clicked", ->
|
||||
it "sets the packagesWithSnippetsDisabled config to include the package name", ->
|
||||
[pack, card] = []
|
||||
snippetsModule = []
|
||||
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'language-test'))
|
||||
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage('snippets').then (p) ->
|
||||
snippetsModule = p.mainModule
|
||||
return unless snippetsModule.provideSnippets().getUnparsedSnippets?
|
||||
|
||||
SnippetsProvider =
|
||||
getSnippets: -> snippetsModule.provideSnippets().getUnparsedSnippets()
|
||||
|
||||
waitsFor 'snippets to load', -> snippetsModule.provideSnippets().bundledSnippetsLoaded()
|
||||
|
||||
runs ->
|
||||
pack = atom.packages.getActivePackage('language-test')
|
||||
card = new PackageSnippetsView(pack, SnippetsProvider)
|
||||
jasmine.attachToDOM(card.element)
|
||||
|
||||
card.refs.snippetToggle.click()
|
||||
expect(card.refs.snippetToggle.checked).toBe false
|
||||
expect(_.include(atom.config.get('core.packagesWithSnippetsDisabled') ? [], 'language-test')).toBe true
|
||||
|
||||
waitsFor 'snippets table to update', ->
|
||||
card.refs.snippets.classList.contains('text-subtle')
|
||||
|
||||
runs ->
|
||||
card.refs.snippetToggle.click()
|
||||
expect(card.refs.snippetToggle.checked).toBe true
|
||||
expect(_.include(atom.config.get('core.packagesWithSnippetsDisabled') ? [], 'language-test')).toBe false
|
||||
|
||||
waitsFor 'snippets table to update', ->
|
||||
not card.refs.snippets.classList.contains('text-subtle')
|
||||
|
||||
it "does not display keybindings from other platforms", ->
|
||||
keybindingsTable = null
|
||||
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'language-test'))
|
||||
|
||||
runs ->
|
||||
pack = atom.packages.getActivePackage('language-test')
|
||||
view = new PackageDetailView(pack, new SettingsView(), new PackageManager(), SnippetsProvider)
|
||||
keybindingsTable = view.element.querySelector('.package-keymap-table tbody')
|
||||
expect(keybindingsTable.children.length).toBe 1
|
||||
|
||||
describe "when the keybindings toggle is clicked", ->
|
||||
it "sets the packagesWithKeymapsDisabled config to include the package name", ->
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'language-test'))
|
||||
|
||||
runs ->
|
||||
pack = atom.packages.getActivePackage('language-test')
|
||||
card = new PackageKeymapView(pack)
|
||||
jasmine.attachToDOM(card.element)
|
||||
|
||||
card.refs.keybindingToggle.click()
|
||||
expect(card.refs.keybindingToggle.checked).toBe false
|
||||
expect(_.include(atom.config.get('core.packagesWithKeymapsDisabled') ? [], 'language-test')).toBe true
|
||||
|
||||
if atom.keymaps.build?
|
||||
keybindingRows = card.element.querySelectorAll('.package-keymap-table tbody.text-subtle tr')
|
||||
expect(keybindingRows.length).toBe 1
|
||||
|
||||
card.refs.keybindingToggle.click()
|
||||
expect(card.refs.keybindingToggle.checked).toBe true
|
||||
expect(_.include(atom.config.get('core.packagesWithKeymapsDisabled') ? [], 'language-test')).toBe false
|
||||
|
||||
if atom.keymaps.build?
|
||||
keybindingRows = card.element.querySelectorAll('.package-keymap-table tbody tr')
|
||||
expect(keybindingRows.length).toBe 1
|
||||
|
||||
describe "when a keybinding is copied", ->
|
||||
[pack, card] = []
|
||||
|
||||
beforeEach ->
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'language-test'))
|
||||
|
||||
runs ->
|
||||
pack = atom.packages.getActivePackage('language-test')
|
||||
card = new PackageKeymapView(pack)
|
||||
|
||||
describe "when the keybinding file ends in .cson", ->
|
||||
it "writes a CSON snippet to the clipboard", ->
|
||||
spyOn(atom.keymaps, 'getUserKeymapPath').andReturn 'keymap.cson'
|
||||
card.element.querySelector('.copy-icon').click()
|
||||
expect(atom.clipboard.read()).toBe """
|
||||
'test':
|
||||
'cmd-g': 'language-test:run'
|
||||
"""
|
||||
|
||||
describe "when the keybinding file ends in .json", ->
|
||||
it "writes a JSON snippet to the clipboard", ->
|
||||
spyOn(atom.keymaps, 'getUserKeymapPath').andReturn 'keymap.json'
|
||||
card.element.querySelector('.copy-icon').click()
|
||||
expect(atom.clipboard.read()).toBe """
|
||||
"test": {
|
||||
"cmd-g": "language-test:run"
|
||||
}
|
||||
"""
|
||||
|
||||
describe "when the package is active", ->
|
||||
it "displays the correct enablement state", ->
|
||||
packageCard = null
|
||||
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage('status-bar')
|
||||
|
||||
runs ->
|
||||
expect(atom.packages.isPackageActive('status-bar')).toBe(true)
|
||||
pack = atom.packages.getLoadedPackage('status-bar')
|
||||
view = new PackageDetailView(pack, new SettingsView(), new PackageManager(), SnippetsProvider)
|
||||
packageCard = view.element.querySelector('.package-card')
|
||||
|
||||
runs ->
|
||||
# Trigger observeDisabledPackages() here
|
||||
# because it is not default in specs
|
||||
atom.packages.observeDisabledPackages()
|
||||
atom.packages.disablePackage('status-bar')
|
||||
expect(atom.packages.isPackageDisabled('status-bar')).toBe(true)
|
||||
expect(packageCard.classList.contains('disabled')).toBe(true)
|
||||
|
||||
describe "when the package is not active", ->
|
||||
it "displays the correct enablement state", ->
|
||||
atom.packages.loadPackage('status-bar')
|
||||
expect(atom.packages.isPackageActive('status-bar')).toBe(false)
|
||||
pack = atom.packages.getLoadedPackage('status-bar')
|
||||
view = new PackageDetailView(pack, new SettingsView(), new PackageManager(), SnippetsProvider)
|
||||
packageCard = view.element.querySelector('.package-card')
|
||||
|
||||
# Trigger observeDisabledPackages() here
|
||||
# because it is not default in specs
|
||||
atom.packages.observeDisabledPackages()
|
||||
atom.packages.disablePackage('status-bar')
|
||||
expect(atom.packages.isPackageDisabled('status-bar')).toBe(true)
|
||||
expect(packageCard.classList.contains('disabled')).toBe(true)
|
||||
|
||||
it "still loads the config schema for the package", ->
|
||||
atom.packages.loadPackage(path.join(__dirname, 'fixtures', 'package-with-config'))
|
||||
|
||||
waitsFor ->
|
||||
atom.packages.isPackageLoaded('package-with-config') is true
|
||||
|
||||
runs ->
|
||||
expect(atom.config.get('package-with-config.setting')).toBe undefined
|
||||
|
||||
pack = atom.packages.getLoadedPackage('package-with-config')
|
||||
new PackageDetailView(pack, new SettingsView(), new PackageManager(), SnippetsProvider)
|
||||
|
||||
expect(atom.config.get('package-with-config.setting')).toBe 'something'
|
||||
|
||||
describe "when the package was not installed from atom.io", ->
|
||||
normalizePackageDataReadmeError = 'ERROR: No README data found!'
|
||||
|
||||
it "still displays the Readme", ->
|
||||
atom.packages.loadPackage(path.join(__dirname, 'fixtures', 'package-with-readme'))
|
||||
|
||||
waitsFor ->
|
||||
atom.packages.isPackageLoaded('package-with-readme') is true
|
||||
|
||||
runs ->
|
||||
pack = atom.packages.getLoadedPackage('package-with-readme')
|
||||
expect(pack.metadata.readme).toBe normalizePackageDataReadmeError
|
||||
|
||||
view = new PackageDetailView(pack, new SettingsView(), new PackageManager(), SnippetsProvider)
|
||||
expect(view.refs.sections.querySelector('.package-readme').textContent).not.toBe normalizePackageDataReadmeError
|
||||
expect(view.refs.sections.querySelector('.package-readme').textContent.trim()).toContain 'I am a Readme!'
|
517
packages/settings-view/spec/installed-package-view-spec.js
Normal file
517
packages/settings-view/spec/installed-package-view-spec.js
Normal file
@ -0,0 +1,517 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS104: Avoid inline assignments
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
|
||||
|
||||
const path = require('path');
|
||||
const PackageDetailView = require('../lib/package-detail-view');
|
||||
const PackageManager = require('../lib/package-manager');
|
||||
const SettingsView = require('../lib/settings-view');
|
||||
const PackageKeymapView = require('../lib/package-keymap-view');
|
||||
const PackageSnippetsView = require('../lib/package-snippets-view');
|
||||
const _ = require('underscore-plus');
|
||||
|
||||
let SnippetsProvider = {
|
||||
getSnippets() {
|
||||
return atom.config.scopedSettingsStore.propertySets;
|
||||
}
|
||||
};
|
||||
|
||||
describe("InstalledPackageView", function() {
|
||||
beforeEach(() => {
|
||||
spyOn(PackageManager.prototype, 'loadCompatiblePackageVersion')
|
||||
.andCallFake(() => {});
|
||||
});
|
||||
|
||||
it("displays the grammars registered by the package", () => {
|
||||
let settingsPanels = null;
|
||||
|
||||
waitsForPromise(() => {
|
||||
return atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'language-test'));
|
||||
});
|
||||
|
||||
runs(() => {
|
||||
const pack = atom.packages.getActivePackage('language-test');
|
||||
const view = new PackageDetailView(pack, new SettingsView(), new PackageManager(), SnippetsProvider);
|
||||
settingsPanels = view.element.querySelectorAll('.package-grammars .settings-panel');
|
||||
|
||||
waitsFor(() => {
|
||||
const children = Array.from(settingsPanels).map(s => s.children.length);
|
||||
const childrenCount = children.reduce(((a, b) => a + b), 0);
|
||||
return childrenCount === 2;
|
||||
});
|
||||
|
||||
expect(
|
||||
settingsPanels[0].querySelector('.grammar-scope').textContent
|
||||
).toBe('Scope: source.a');
|
||||
expect(
|
||||
settingsPanels[0].querySelector('.grammar-filetypes'
|
||||
).textContent).toBe('File Types: .a, .aa, a');
|
||||
|
||||
expect(
|
||||
settingsPanels[1].querySelector('.grammar-scope').textContent
|
||||
).toBe('Scope: source.b');
|
||||
expect(
|
||||
settingsPanels[1].querySelector('.grammar-filetypes').textContent
|
||||
).toBe('File Types: ');
|
||||
|
||||
expect(settingsPanels[2]).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
it("displays the snippets registered by the package", () => {
|
||||
let snippetsTable = null;
|
||||
let snippetsModule = null;
|
||||
|
||||
// Relies on behavior not present in the snippets package before 1.103.
|
||||
const shouldRunScopeTest = parseFloat(atom.getVersion()) >= 1.103;
|
||||
|
||||
waitsForPromise(() => {
|
||||
return atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'language-test'));
|
||||
});
|
||||
|
||||
waitsForPromise(() => {
|
||||
return atom.packages.activatePackage('snippets').then((p) => {
|
||||
snippetsModule = p.mainModule;
|
||||
if (snippetsModule.provideSnippets().getUnparsedSnippets == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SnippetsProvider = {
|
||||
getSnippets() {
|
||||
return snippetsModule.provideSnippets().getUnparsedSnippets();
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
waitsFor('snippets to load', () => {
|
||||
return snippetsModule.provideSnippets().bundledSnippetsLoaded();
|
||||
});
|
||||
|
||||
runs(() => {
|
||||
const pack = atom.packages.getActivePackage('language-test');
|
||||
const view = new PackageDetailView(pack, new SettingsView(), new PackageManager(), SnippetsProvider);
|
||||
snippetsTable = view.element.querySelector('.package-snippets-table tbody');
|
||||
});
|
||||
|
||||
waitsFor('snippets table children to contain 2 items', () => {
|
||||
return snippetsTable.children.length >= 2;
|
||||
});
|
||||
|
||||
runs(() => {
|
||||
expect(
|
||||
snippetsTable.querySelector('tr:nth-child(1) td:nth-child(1)').textContent
|
||||
).toBe('b');
|
||||
if (shouldRunScopeTest) {
|
||||
expect(
|
||||
snippetsTable.querySelector('tr:nth-child(1) td:nth-child(2)').textContent
|
||||
).toBe('language-test:sample-command');
|
||||
}
|
||||
expect(
|
||||
snippetsTable.querySelector('tr:nth-child(1) td:nth-child(3)'
|
||||
).textContent).toBe('BAR');
|
||||
|
||||
if (shouldRunScopeTest) {
|
||||
expect(
|
||||
snippetsTable.querySelector('tr:nth-child(1) td.snippet-scope-name').textContent
|
||||
).toBe('.source.b');
|
||||
}
|
||||
|
||||
expect(
|
||||
snippetsTable.querySelector('tr:nth-child(2) td:nth-child(1)').textContent
|
||||
).toBe('f');
|
||||
|
||||
if (shouldRunScopeTest) {
|
||||
expect(
|
||||
snippetsTable.querySelector('tr:nth-child(1) td:nth-child(2)').textContent
|
||||
).toBe('');
|
||||
}
|
||||
expect(
|
||||
snippetsTable.querySelector('tr:nth-child(2) td:nth-child(3)').textContent
|
||||
).toBe('FOO');
|
||||
|
||||
if (shouldRunScopeTest) {
|
||||
expect(
|
||||
snippetsTable.querySelector('tr:nth-child(2) td.snippet-scope-name').textContent
|
||||
).toBe('.source.a, .source.aa');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("when a snippet body is viewed", () =>
|
||||
it("shows a tooltip", () => {
|
||||
let view = null;
|
||||
let snippetsTable = null;
|
||||
let snippetsModule = null;
|
||||
|
||||
waitsForPromise(() => {
|
||||
return atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'language-test'));
|
||||
});
|
||||
|
||||
waitsForPromise(() =>
|
||||
atom.packages.activatePackage('snippets').then((p) => {
|
||||
snippetsModule = p.mainModule;
|
||||
if (snippetsModule.provideSnippets().getUnparsedSnippets == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SnippetsProvider = {
|
||||
getSnippets() {
|
||||
return snippetsModule.provideSnippets().getUnparsedSnippets();
|
||||
}
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
waitsFor('snippets to load', () => {
|
||||
return snippetsModule.provideSnippets().bundledSnippetsLoaded();
|
||||
});
|
||||
|
||||
runs(() => {
|
||||
const pack = atom.packages.getActivePackage('language-test');
|
||||
view = new PackageDetailView(pack, new SettingsView(), new PackageManager(), SnippetsProvider);
|
||||
snippetsTable = view.element.querySelector('.package-snippets-table tbody');
|
||||
});
|
||||
|
||||
waitsFor('snippets table children to contain 2 items', () => snippetsTable.children.length >= 2);
|
||||
|
||||
runs(() => {
|
||||
expect(
|
||||
view.element.ownerDocument.querySelector('.snippet-body-tooltip')
|
||||
).not.toExist();
|
||||
|
||||
view.element.querySelector(
|
||||
'.package-snippets-table tbody tr:nth-child(1) td.snippet-body .snippet-view-btn'
|
||||
).click();
|
||||
|
||||
expect(
|
||||
view.element.ownerDocument.querySelector('.snippet-body-tooltip')
|
||||
).toExist();
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
// Relies on behavior not present in the snippets package before 1.33.
|
||||
// TODO: These tests should always run once 1.33 is released.
|
||||
if (parseFloat(atom.getVersion()) >= 1.33) {
|
||||
describe("when a snippet is copied", () => {
|
||||
let pack, card;
|
||||
let snippetsTable = null;
|
||||
let snippetsModule = null;
|
||||
|
||||
beforeEach(() => {
|
||||
waitsForPromise(() => {
|
||||
return atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'language-test'));
|
||||
});
|
||||
|
||||
waitsForPromise(() => {
|
||||
return atom.packages.activatePackage('snippets').then((p) => {
|
||||
snippetsModule = p.mainModule;
|
||||
if (snippetsModule.provideSnippets().getUnparsedSnippets == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SnippetsProvider = {
|
||||
getSnippets() {
|
||||
return snippetsModule.provideSnippets().getUnparsedSnippets();
|
||||
},
|
||||
getUserSnippetsPath: () => snippetsModule.getUserSnippetsPath()
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
waitsFor('snippets to load', () => {
|
||||
return snippetsModule.provideSnippets().bundledSnippetsLoaded();
|
||||
});
|
||||
|
||||
runs(() => {
|
||||
pack = atom.packages.getActivePackage('language-test');
|
||||
card = new PackageSnippetsView(pack, SnippetsProvider);
|
||||
snippetsTable = card.element.querySelector('.package-snippets-table tbody');
|
||||
});
|
||||
|
||||
waitsFor('snippets table children to contain 2 items', () => snippetsTable.children.length >= 2);
|
||||
});
|
||||
|
||||
describe("when the snippets file ends in .cson", () =>
|
||||
it("writes a CSON snippet to the clipboard", () => {
|
||||
spyOn(SnippetsProvider, 'getUserSnippetsPath').andReturn('snippets.cson');
|
||||
card.element.querySelector(
|
||||
'.package-snippets-table tbody tr:nth-child(1) td.snippet-body .snippet-copy-btn'
|
||||
).click();
|
||||
expect(atom.clipboard.read()).toBe(`\
|
||||
\n'.b.source':
|
||||
'BAR':
|
||||
'prefix': 'b'
|
||||
'body': 'bar?\\nline two'\n\
|
||||
`
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
describe("when the snippets file ends in .json", () =>
|
||||
it("writes a JSON snippet to the clipboard", () => {
|
||||
spyOn(SnippetsProvider, 'getUserSnippetsPath').andReturn('snippets.json');
|
||||
card.element.querySelector(
|
||||
'.package-snippets-table tbody tr:nth-child(1) td.snippet-body .btn:nth-child(2)'
|
||||
).click();
|
||||
expect(atom.clipboard.read()).toBe(`\
|
||||
\n ".b.source": {
|
||||
"BAR": {
|
||||
"prefix": "b",
|
||||
"body": "bar?\\nline two"
|
||||
}
|
||||
}\n\
|
||||
`
|
||||
);
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
describe("when the snippets toggle is clicked", () =>
|
||||
it("sets the packagesWithSnippetsDisabled config to include the package name", function() {
|
||||
let pack, card;
|
||||
let snippetsModule = null;
|
||||
|
||||
waitsForPromise(() => {
|
||||
return atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'language-test'));
|
||||
});
|
||||
|
||||
waitsForPromise(() =>
|
||||
atom.packages.activatePackage('snippets').then((p) => {
|
||||
snippetsModule = p.mainModule;
|
||||
if (snippetsModule.provideSnippets().getUnparsedSnippets == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
return SnippetsProvider = {
|
||||
getSnippets() {
|
||||
return snippetsModule.provideSnippets().getUnparsedSnippets();
|
||||
}
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
waitsFor('snippets to load', () => {
|
||||
return snippetsModule.provideSnippets().bundledSnippetsLoaded();
|
||||
});
|
||||
|
||||
runs(() => {
|
||||
pack = atom.packages.getActivePackage('language-test');
|
||||
card = new PackageSnippetsView(pack, SnippetsProvider);
|
||||
jasmine.attachToDOM(card.element);
|
||||
|
||||
card.refs.snippetToggle.click();
|
||||
expect(card.refs.snippetToggle.checked).toBe(false);
|
||||
let disabledSnippetsPackages = atom.config.get('core.packagesWithSnippetsDisabled') || [];
|
||||
expect(
|
||||
_.include(disabledSnippetsPackages, 'language-test')
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
waitsFor('snippets table to update', () => {
|
||||
return card.refs.snippets.classList.contains('text-subtle');
|
||||
});
|
||||
|
||||
runs(() => {
|
||||
card.refs.snippetToggle.click();
|
||||
expect(card.refs.snippetToggle.checked).toBe(true);
|
||||
let disabledSnippetsPackages = atom.config.get('core.packagesWithSnippetsDisabled') || [];
|
||||
expect(
|
||||
_.include(disabledSnippetsPackages, 'language-test')
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
waitsFor('snippets table to update', () => {
|
||||
return !card.refs.snippets.classList.contains('text-subtle');
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
it("does not display keybindings from other platforms", () => {
|
||||
let keybindingsTable = null;
|
||||
|
||||
waitsForPromise(() => {
|
||||
return atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'language-test'));
|
||||
});
|
||||
|
||||
runs(() => {
|
||||
const pack = atom.packages.getActivePackage('language-test');
|
||||
const view = new PackageDetailView(pack, new SettingsView(), new PackageManager(), SnippetsProvider);
|
||||
keybindingsTable = view.element.querySelector('.package-keymap-table tbody');
|
||||
expect(keybindingsTable.children.length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the keybindings toggle is clicked", () =>
|
||||
it("sets the packagesWithKeymapsDisabled config to include the package name", () => {
|
||||
waitsForPromise(() => {
|
||||
return atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'language-test'));
|
||||
});
|
||||
|
||||
runs(() => {
|
||||
let keybindingRows;
|
||||
const pack = atom.packages.getActivePackage('language-test');
|
||||
const card = new PackageKeymapView(pack);
|
||||
jasmine.attachToDOM(card.element);
|
||||
|
||||
card.refs.keybindingToggle.click();
|
||||
expect(card.refs.keybindingToggle.checked).toBe(false);
|
||||
let disabledKeymapsPackages = atom.config.get('core.packagesWithKeymapsDisabled') || [];
|
||||
expect(
|
||||
_.include(disabledKeymapsPackages, 'language-test')
|
||||
).toBe(true);
|
||||
|
||||
if (atom.keymaps.build) {
|
||||
keybindingRows = card.element.querySelectorAll('.package-keymap-table tbody.text-subtle tr');
|
||||
expect(keybindingRows.length).toBe(1);
|
||||
}
|
||||
|
||||
card.refs.keybindingToggle.click();
|
||||
expect(card.refs.keybindingToggle.checked).toBe(true);
|
||||
disabledKeymapsPackages = atom.config.get('core.packagesWithKeymapsDisabled') || [];
|
||||
|
||||
expect(
|
||||
_.include(disabledKeymapsPackages, 'language-test')
|
||||
).toBe(false);
|
||||
|
||||
if (atom.keymaps.build) {
|
||||
keybindingRows = card.element.querySelectorAll('.package-keymap-table tbody tr');
|
||||
expect(keybindingRows.length).toBe(1);
|
||||
}
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
describe("when a keybinding is copied", () => {
|
||||
let [pack, card] = Array.from([]);
|
||||
|
||||
beforeEach(() => {
|
||||
waitsForPromise(() => {
|
||||
return atom.packages.activatePackage(path.join(__dirname, 'fixtures', 'language-test'));
|
||||
});
|
||||
|
||||
runs(() => {
|
||||
pack = atom.packages.getActivePackage('language-test');
|
||||
card = new PackageKeymapView(pack);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the keybinding file ends in .cson", () =>
|
||||
it("writes a CSON snippet to the clipboard", () => {
|
||||
spyOn(atom.keymaps, 'getUserKeymapPath').andReturn('keymap.cson');
|
||||
card.element.querySelector('.copy-icon').click();
|
||||
expect(atom.clipboard.read()).toBe(`\
|
||||
'test':
|
||||
'cmd-g': 'language-test:run'\
|
||||
`
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
describe("when the keybinding file ends in .json", () => {
|
||||
it("writes a JSON snippet to the clipboard", () => {
|
||||
spyOn(atom.keymaps, 'getUserKeymapPath').andReturn('keymap.json');
|
||||
card.element.querySelector('.copy-icon').click();
|
||||
expect(atom.clipboard.read()).toBe(`\
|
||||
"test": {
|
||||
"cmd-g": "language-test:run"
|
||||
}\
|
||||
`
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the package is active", () =>
|
||||
it("displays the correct enablement state", () => {
|
||||
let packageCard = null;
|
||||
|
||||
waitsForPromise(() => {
|
||||
return atom.packages.activatePackage('status-bar');
|
||||
});
|
||||
|
||||
runs(() => {
|
||||
expect(atom.packages.isPackageActive('status-bar')).toBe(true);
|
||||
const pack = atom.packages.getLoadedPackage('status-bar');
|
||||
const view = new PackageDetailView(pack, new SettingsView(), new PackageManager(), SnippetsProvider);
|
||||
packageCard = view.element.querySelector('.package-card');
|
||||
});
|
||||
|
||||
runs(() => {
|
||||
// Trigger observeDisabledPackages() here
|
||||
// because it is not default in specs
|
||||
atom.packages.observeDisabledPackages();
|
||||
atom.packages.disablePackage('status-bar');
|
||||
expect(atom.packages.isPackageDisabled('status-bar')).toBe(true);
|
||||
expect(packageCard.classList.contains('disabled')).toBe(true);
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
describe("when the package is not active", () => {
|
||||
it("displays the correct enablement state", () => {
|
||||
atom.packages.loadPackage('status-bar');
|
||||
expect(atom.packages.isPackageActive('status-bar')).toBe(false);
|
||||
const pack = atom.packages.getLoadedPackage('status-bar');
|
||||
const view = new PackageDetailView(pack, new SettingsView(), new PackageManager(), SnippetsProvider);
|
||||
const packageCard = view.element.querySelector('.package-card');
|
||||
|
||||
// Trigger observeDisabledPackages() here
|
||||
// because it is not default in specs
|
||||
atom.packages.observeDisabledPackages();
|
||||
atom.packages.disablePackage('status-bar');
|
||||
expect(atom.packages.isPackageDisabled('status-bar')).toBe(true);
|
||||
expect(packageCard.classList.contains('disabled')).toBe(true);
|
||||
});
|
||||
|
||||
it("still loads the config schema for the package", () => {
|
||||
atom.packages.loadPackage(path.join(__dirname, 'fixtures', 'package-with-config'));
|
||||
|
||||
waitsFor(() => atom.packages.isPackageLoaded('package-with-config') === true);
|
||||
|
||||
runs(() => {
|
||||
expect(atom.config.get('package-with-config.setting')).toBe(undefined);
|
||||
|
||||
const pack = atom.packages.getLoadedPackage('package-with-config');
|
||||
new PackageDetailView(pack, new SettingsView(), new PackageManager(), SnippetsProvider);
|
||||
|
||||
expect(atom.config.get('package-with-config.setting')).toBe('something');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the package was not installed from atom.io", () => {
|
||||
const normalizePackageDataReadmeError = 'ERROR: No README data found!';
|
||||
|
||||
it("still displays the Readme", () => {
|
||||
atom.packages.loadPackage(path.join(__dirname, 'fixtures', 'package-with-readme'));
|
||||
|
||||
waitsFor(() => {
|
||||
return atom.packages.isPackageLoaded('package-with-readme') === true;
|
||||
});
|
||||
|
||||
runs(() => {
|
||||
const pack = atom.packages.getLoadedPackage('package-with-readme');
|
||||
expect(pack.metadata.readme).toBe(normalizePackageDataReadmeError);
|
||||
|
||||
const view = new PackageDetailView(pack, new SettingsView(), new PackageManager(), SnippetsProvider);
|
||||
expect(
|
||||
view.refs.sections.querySelector('.package-readme').textContent
|
||||
).not.toBe(normalizePackageDataReadmeError);
|
||||
expect(
|
||||
view.refs.sections.querySelector('.package-readme').textContent.trim()
|
||||
).toContain('I am a Readme!');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -37,8 +37,6 @@ async function modifyMainPackageJson(file, extraMetadata, isRemovePackageScripts
|
||||
/// END Monkey-Patch
|
||||
|
||||
const builder = require("electron-builder")
|
||||
const Platform = builder.Platform
|
||||
|
||||
|
||||
const pngIcon = 'resources/app-icons/beta.png'
|
||||
const icoIcon = 'resources/app-icons/beta.ico'
|
||||
@ -219,7 +217,7 @@ let options = {
|
||||
],
|
||||
"target": [
|
||||
{ "target": "nsis" },
|
||||
{ "target": "portable" },
|
||||
{ target: "zip" },
|
||||
],
|
||||
},
|
||||
// Windows NSIS Configuration
|
||||
@ -262,7 +260,6 @@ async function main() {
|
||||
let options = whatToBuild()
|
||||
options.extraMetadata = generateMetadata(JSON.parse(package))
|
||||
builder.build({
|
||||
//targets: Platform.LINUX.createTarget(),
|
||||
config: options
|
||||
}).then((result) => {
|
||||
console.log("Built binaries")
|
||||
|
Loading…
Reference in New Issue
Block a user