forked from palantir/blueprint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request palantir#56 from blueberryapps/add-ava-tests
Add tests
- Loading branch information
Showing
30 changed files
with
181 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ dependencies: | |
|
||
test: | ||
override: | ||
- gulp ava | ||
- cd example && gulp: | ||
background: true | ||
- sleep 10 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import buildProps from '../buildProps'; | ||
import test from 'ava'; | ||
|
||
test('build props', t => { | ||
const props = { | ||
anyProp: {type: {name: 'any'}, required: false}, | ||
nodeProp: {type: {name: 'node'}, required: false}, | ||
stringPropDefault: {type: {name: 'string'}, required: true, defaultValue: {value: '\'text\'', computed: true}}, | ||
stringPropDefaultFalse: {type: {name: 'string'}, required: true, defaultValue: {value: '\'text\'', computed: false}}, | ||
stringProp: {type: {name: 'string'}, required: true}, | ||
boolProp: {type: {name: 'bool'}, required: false}, | ||
numberProp: {type: {name: 'number'}, required: false}, | ||
arrayProp: {type: {name: 'array'}, required: false}, | ||
objectProp: {type: {name: 'object'}, required: false}, | ||
funcProp: {type: {name: 'func'}, required: false}, | ||
enumProps: {type: {name: 'enum', value: 'asd'}, required: false}, | ||
shapeProps: {type: {name: 'shape', value: {deepValue: 'asd', Qww: 'qwert'}}, required: false}, | ||
arrayOfProp: {type: {name: 'arrayOf', value: {nextValue: 'asd', PPoo: 'pppp'}}, required: false}, | ||
} | ||
|
||
const builtProps = buildProps(props, true) | ||
const arrayOfProps = [ | ||
builtProps.arrayOfProp instanceof Array, | ||
typeof builtProps.objectProp === 'object', | ||
builtProps.nodeProp === 'NODE nodeProp', | ||
typeof builtProps.funcProp === 'function', | ||
typeof builtProps.numberProp === 'number' && builtProps.numberProp === 1, | ||
builtProps.stringPropDefault === '\'text\'', | ||
builtProps.boolProp === true || false, | ||
typeof builtProps.enumProps === 'string', | ||
typeof builtProps.shapeProps === 'object', | ||
builtProps.anyProp === 'ANY anyProp', | ||
builtProps.stringProp === 'stringProp', | ||
builtProps.stringPropDefaultFalse === 'text', | ||
builtProps.arrayProp instanceof Array | ||
] | ||
const result = arrayOfProps.reduce((acc, prop) => acc && prop, true) | ||
|
||
t.true(result) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import filterFunctionProps from '../filterFunctionProps'; | ||
import test from 'ava'; | ||
|
||
test('filter function props', t => { | ||
const props = { | ||
width: 'full', | ||
disabled: true, | ||
size: 6, | ||
onClick: () => 'Test function' | ||
} | ||
const filteredProps = filterFunctionProps(props) | ||
const count = Object.keys(filteredProps).length | ||
const functionPropName = Object.keys(filteredProps) | ||
.reduce((acc, key) => { | ||
if (typeof filteredProps[key] === 'function') | ||
acc.push(key) | ||
return acc; | ||
}, []) | ||
.indexOf('Test function') === -1 | ||
|
||
t.true(count === 3 && functionPropName) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import generateTree from '../generateTree'; | ||
import {Map} from 'immutable'; | ||
import test from 'ava'; | ||
|
||
test('generate components tree', t => { | ||
const componentsIndex = Map({ | ||
ExampleFolderButton: Map({ | ||
menu: 'Example Folder Button', | ||
name: 'ExampleFolderButton' | ||
}) | ||
}) | ||
const tree = generateTree(componentsIndex) | ||
const name = tree.getIn(['Example', 'Folder', 'Button']) | ||
const isMap = tree ? Map.isMap(tree) : false | ||
const result = isMap && name === 'ExampleFolderButton' | ||
t.true(result) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import normalizePath from '../normalizePath'; | ||
import test from 'ava'; | ||
|
||
test('replace with \'\\\'', t => { | ||
const text = '\\folder\\folder\\file.js' | ||
const result = normalizePath(text, '\\') | ||
t.true(result === '/folder/folder/file.js') | ||
}); | ||
|
||
test('replace without \'\\\'', t => { | ||
const text = 'folder/folder/file.js' | ||
const result = normalizePath(text) | ||
t.true(result === 'folder/folder/file.js') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import parseHighlightedMenu from '../parseHighlightedMenu'; | ||
import test from 'ava'; | ||
|
||
test('parse highlighted', t => { | ||
const result = parseHighlightedMenu('<bstyle=\"color:red\">Text</b>') | ||
t.true(result === '<b style=\"color:red\">Text</b>') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import renderProp from '../renderProp'; | ||
import test from 'ava'; | ||
|
||
test('passed func', t => { | ||
const result = renderProp('key', 'func', 'value') | ||
t.true(result === 'key={() => alert(\'INSERT YOUR key function\')}') | ||
}); | ||
|
||
test('passed object', t => { | ||
const result = renderProp('key', 'object', {object: 'objectKey'}) | ||
t.true(result === 'key={{\"object\":\"objectKey\"}}') | ||
}); | ||
|
||
test('passed bool', t => { | ||
const result = renderProp('key', 'bool', true) | ||
t.true(result === 'key={true}') | ||
}); | ||
|
||
test('passed element', t => { | ||
const result = renderProp('key', 'element', 'value') | ||
t.true(result === 'key={value}') | ||
}); | ||
|
||
test('passed node', t => { | ||
const result = renderProp('key', 'node', 'value') | ||
t.true(result === 'key={value}') | ||
}); | ||
|
||
test('passed number', t => { | ||
const result = renderProp('key', 'number', 6) | ||
t.true(result === 'key={6}') | ||
}); | ||
|
||
test('passed everything else', t => { | ||
const result = renderProp('key', 'number', 'value') | ||
t.true(result === 'key=\"value\"') | ||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import path from 'path'; | ||
|
||
export default function normalizePath(str, separator = path.sep) { | ||
if (separator === '\\') { | ||
str = str.replace(/\\/g, '/'); | ||
} | ||
return str; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.