Skip to content
This repository was archived by the owner on Jul 27, 2024. It is now read-only.

Commit 302810c

Browse files
committed
✅ Add settings specs
To support the changes in #6, this spec suite performs an empty diff file load, adds some text with trailing spaces, and saves it. With the default settings for the package, it should never trim whiespace if the whitespace package is enabled. Signed-off-by: Mike Fiedler <[email protected]>
1 parent 2274133 commit 302810c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

spec/settings-spec.coffee

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
path = require 'path'
2+
temp = require 'temp'
3+
4+
describe 'Settings', ->
5+
editor = []
6+
7+
beforeEach ->
8+
directory = temp.mkdirSync()
9+
atom.project.setPaths([directory])
10+
filePath = path.join(directory, 'atom.diff')
11+
12+
waitsForPromise ->
13+
atom.workspace.open(filePath).then (o) -> editor = o
14+
waitsForPromise ->
15+
atom.packages.activatePackage('whitespace')
16+
waitsForPromise ->
17+
atom.packages.activatePackage('language-diff')
18+
19+
it 'loads both packages', ->
20+
expect(atom.packages.isPackageActive('whitespace')).toBe true
21+
expect(atom.packages.isPackageActive('language-diff')).toBe true
22+
23+
it 'sets the grammar', ->
24+
expect(editor.getGrammar().name).toBe 'Diff'
25+
26+
it 'sets the whitespace config to false', ->
27+
expect(editor.config.get('whitespace.removeTrailingWhitespace', scope: ['.source.diff'])).toBe false
28+
29+
it 'does not trim trailing whitespace', ->
30+
editor.insertText "+def fib(n, sequence = [1]) \n"
31+
editor.save()
32+
expect(editor.getText()).toBe "+def fib(n, sequence = [1]) \n"

0 commit comments

Comments
 (0)