Skip to content

Commit 6f496ba

Browse files
Added test package.
1 parent eea1986 commit 6f496ba

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
"
2+
A CmUICommandTest is a test class for testing the behavior of CmUICommand
3+
"
4+
Class {
5+
#name : #CmUICommandTest,
6+
#superclass : #TestCase,
7+
#instVars : [
8+
'command'
9+
],
10+
#category : #'Commander2-UI-Tests-Core'
11+
}
12+
13+
{ #category : #helpers }
14+
CmUICommandTest >> banana [
15+
"Does not return an icon, it is not needed for the test."
16+
^ 42
17+
]
18+
19+
{ #category : #helpers }
20+
CmUICommandTest >> iconNamed: aSymbol [
21+
aSymbol ~= #banana
22+
ifTrue: [ self error: 'Only #banana icon is needed for tests.' ].
23+
24+
^ self banana
25+
]
26+
27+
{ #category : #running }
28+
CmUICommandTest >> setUp [
29+
super setUp.
30+
command := CmUICommand new
31+
]
32+
33+
{ #category : #tests }
34+
CmUICommandTest >> testHasIcon [
35+
self deny: command hasIcon.
36+
37+
command iconName: #banana.
38+
39+
self assert: command hasIcon
40+
]
41+
42+
{ #category : #tests }
43+
CmUICommandTest >> testHasShortcutKey [
44+
self deny: command hasShortcutKey.
45+
46+
command shortcutKey: $a asKeyCombination.
47+
48+
self assert: command hasShortcutKey.
49+
]
50+
51+
{ #category : #tests }
52+
CmUICommandTest >> testIcon [
53+
self assert: command icon isNil.
54+
55+
command iconName: #add.
56+
57+
self assert: command icon equals: (command iconNamed: #add).
58+
]
59+
60+
{ #category : #tests }
61+
CmUICommandTest >> testIconName [
62+
self assert: command iconName isNil.
63+
64+
command iconName: #add.
65+
66+
self assert: command iconName equals: #add
67+
68+
69+
]
70+
71+
{ #category : #tests }
72+
CmUICommandTest >> testIconNameFrom [
73+
self assert: command iconProvider equals: Smalltalk ui icons.
74+
75+
command iconName: #banana from: self.
76+
77+
self assert: command iconProvider equals: self.
78+
self assert: (command icon) equals: self banana
79+
]
80+
81+
{ #category : #tests }
82+
CmUICommandTest >> testIconProvider [
83+
self assert: command iconProvider equals: Smalltalk ui icons.
84+
85+
command iconProvider: self.
86+
87+
self assert: command iconProvider equals: self.
88+
89+
command iconName: #banana.
90+
self assert: (command icon) equals: self banana
91+
]
92+
93+
{ #category : #tests }
94+
CmUICommandTest >> testShortcutKey [
95+
self should: [ command shortcutKey ] raise: CmNoShortcutIsDefined.
96+
97+
command shortcutKey: $a asKeyCombination.
98+
99+
self assert: command shortcutKey equals: $a asKeyCombination
100+
]

src/Commander2-UI-Tests/package.st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Package { #name : #'Commander2-UI-Tests' }

0 commit comments

Comments
 (0)